Kerakli kodlar
( project upload to git ):
git init
git init --initial-branch=main
git remote add origin https://git.quantic.uz/web-intern/ordery-management.git
git add . (hammasini qo’shish)
git commit -m "Ordery Management project created"(koment qo’shish”)
git push -u origin main
Push project :
1.git add .
2.git commit –m “coment qoshamiz”
3.git push
Proyektdagi muammolar:
1.registrationda kamchilik bor.(fully completed !)
2.permissionsda kamchilik bor.
3.Payment qismi hali qilinmadi.(Erkin bn birga qilamiz)
4.OrderServiceda navbatni aniqlash(fully completed !)
5.pip install -r requirements.txt
class UserRegistrationSerializer(serializers.ModelSerializer):
password2 = serializers.CharField(style={'input_type':'password'}, write_only=True)
class Meta:
model = User
fields = ['username', 'email', 'first_name','last_name',
'password', 'password2',]
extra_kwargs = {
'password': {
'write_only':True
}
}
def save(self):
user = User(
email=self.validated_data['email'],
username=self.validated_data['username'],
first_name=self.validated_data['first_name'],
last_name=self.validated_data['last_name'],
is_tutor=self.validated_data['is_tutor'],
is_student=self.validated_data['is_student'],
)
password = self.validated_data['password']
password2 = self.validated_data['password2']
if password != password2:
raise serializers.ValidationError({'password':'Passwords must match.'})
user.set_password(password)
user.save()
return user
Change Password :
from django.contrib.auth import password_validation
from django.utils.translation import gettext_lazy as _
from rest_framework import serializers
class ChangePasswordSerializer(serializers.Serializer):
old_password = serializers.CharField(max_length=128, write_only=True, required=True)
new_password1 = serializers.CharField(max_length=128, write_only=True, required=True)
new_password2 = serializers.CharField(max_length=128, write_only=True, required=True)
def validate_old_password(self, value):
user = self.context['request'].user
if not user.check_password(value):
raise serializers.ValidationError(
_('Your old password was entered incorrectly. Please enter it again.')
)
return value
def validate(self, data):
if data['new_password1'] != data['new_password2']:
raise serializers.ValidationError({'new_password2': _("The two password fields didn't match.")})
password_validation.validate_password(data['new_password1'], self.context['request'].user)
return data
def save(self, **kwargs):
password = self.validated_data['new_password1']
user = self.context['request'].user
user.set_password(password)
user.save()
return user
Bot installed libraries:
Django==4.0.1
python-telegram-bot==13.10
https://python-telegram-bot.readthedocs.io/en/stable/telegram.message.html#telegram.Message.forward
!pip install pandas
import pandas as pd
data = {'vaqt': ["8:00", "9:00","10:00","11:00"], 'habar': [48, 65, 85, 72]}
df = pd.DataFrame(data)
with pd.ExcelWriter("data.xlsx") as writer:
df.to_excel(writer, index=False)
Do'stlaringiz bilan baham: |