Difference between revisions of "Create account edit page in Django"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(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...")
(No difference)

Revision as of 19:57, 3 May 2019

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',
            ]