-1

Im experiencing an issue being able to change user profile data traits for users once I set them with the initial form in forms.py to override the generic django settings.

class EditProfileForm(UserChangeForm):

   class Meta:
      model = User
         fields=('username','first_name','last_name','email','street','city','state','zipcode','country',)

It fails when I try this, but works if I remove street, city, state, zipcode, and country, even though the registration form allows it to fill in all of this information.

The original form allows me to set all of this information with the registration form in forms.py without issue, and ive confirmed its working without flaw. However, it wont let me edit the setting once I set it.

Any insight would be absolutely appreciated. I believe it may be because the superuser doesnt have these fields, and if so, if I could set a default='' if thats possible? Im not aware of being able to do that though for previously existing users, and Ive also tried erasing all users and attempting it with no users, but that didnt work either.

Fallenour
  • 62
  • 1
  • 10

1 Answers1

0

Typically when I extend a django auth, I create a new model for the profile than override the user save method to also save a new creation into the extended profile table.

See this answer for more details... Creating a extended user profile

Another solution to this would be to use the new Django Signals to essentially do the same thing but with a more modern API.

https://docs.djangoproject.com/en/2.1/topics/signals/

Chris Hawkes
  • 11,923
  • 6
  • 58
  • 68