22.3.3 Integrating Forms and Templates
When we created our new User
model, we removed the username
field, choosing to use only the email
field for user authentication. This is a bit of a problem because the UserCreationForm
uses the username
to create the Profile
object. The profile_detail.html
also needs to be changed because it calls get_username()
, which will now display the email and needs to instead use get_full_name()
.
This transition away from username
is made possible largely because of the name
field added to the Profile
model. Our goal is thus to ask the user for a value for the name
field and then to use it to create the Profile
, including the generation of the slug
field on Profile
.
Our first change to UserCreationForm
is thus to ...
Get Django Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.