Create account edit page in Django

From TRCCompSci - AQA Computer Science
Revision as of 19:57, 3 May 2019 by Admin (talk | contribs) (Created page with "In the previous tutorial we created a sign up / register page. We now need to create a page to edit the information for the user. =Create the form= In the 'users' app folder...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

In the previous tutorial we created a sign up / register page. We now need to create a page to edit the information for the user.

Create the form

In the 'users' app folder, open 'forms.py'. This should currently have the 'UserRegistrationForm'. Now copy the entire class, and rename it 'UserViewForm'. Also remove the references to 'password1' and 'password2':

class UserViewForm (UserCreationForm):
    email = forms.EmailField(required=True)
    first_name = forms.CharField(required=True)
    last_name = forms.CharField(required=True)

    class Meta:
        model=User
        fields = [
            'username',
            'first_name',
            'last_name',
            'email',
            ]