How can I update the models from this updateprofile function in views.py
views.py
def updateProfile(request):
name = request.POST['name']
email = request.POST['email']
standard = request.POST['standard']
phone = request.POST['phone']
obj, created = Student.objects.update_or_create(name=User.username,
defaults={'email': email, 'standard':standard, 'phone':phone},
)
if created:
messages.info(request, 'Your details are Created!', extra_tags='Congratulations!')
else:
messages.info(request, 'Your details are updated!', extra_tags='Congratulations!')
return redirect('/profile')
models.py
class Student(models.Model):
name = models.CharField(max_length=45, null=False, unique=True)
standard = models.IntegerField(null=True)
phone = models.IntegerField(null=True)
address = models.CharField(max_length=100, null=True)
email = models.EmailField(unique=True)
password = models.CharField(max_length=20, null=True)
def __str__(self):
return f"{self.name} class={self.standard} rollno={self.id}"
Я получаю 500 ошибок каждый раз, когда пытаюсь обновить модель студента .... Пожалуйста, помогите я в этой проблеме