How do I extend UserCreationForm to include email field

前端 未结 3 1865
借酒劲吻你
借酒劲吻你 2021-01-12 01:26

I managed to get the stock standard User Creation Form to work. Which included just the username, password1 and password2 field. However, when I try to include the email fie

3条回答
  •  不要未来只要你来
    2021-01-12 02:28

    You are importing the wrong UserCreationForm in views.py. You should import your own form not the Django's one:

    stories/views.py

    from stories.forms import UserCreationForm
    ...
    

    Besides that, you don't have to wrap all your fields with

    individually as there exists form.as_p() for this job.

    register.html

    {% csrf_token %} {{ form.as_p }}

    Hope this helps.

提交回复
热议问题