Answer the question
In order to leave comments, you need to log in
What is wrong with the form?
Mistake:
return Database.Cursor.execute(self, query, params)
django.db.utils.IntegrityError: UNIQUE constraint failed: user_user.username
class User(AbstractUser):
country = models.CharField(max_length=35, null = True, blank = True)
city = models.CharField(max_length=35, null = True, blank = True)
bio = models.CharField(max_length=150, null = True, blank = True)
image = models.ImageField(upload_to = 'static/images', blank = True)
def __str__(self):
return self.username
class UserSettingsForm(ModelForm):
User = get_user_model()
class Meta:
model = User
fields = ['image']
imgform = UserSettingsForm(request.POST, request.FILES)
if imgform.is_valid():
imgform.save()
return redirect('/user/profile')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question