简体   繁体   中英

How to add custom-fields (First and Last Name) in django-registration 2.2 (HMAC activation Workflow)?

There are already some question on this but most of their answers are using models based workflow which is not a recommended way anymore according to django-registration. I am just frustrated from last week, trying to figure out how to add first and last name fields in registration form in HMAC Workflow.

I am not intimately familiar with django, but an easy solution would be to follow the default registration workflow to let your user register. Then when your user tries to login for the first time you present them with a form to fill with all the extra information you might need.

In this way you also decouple the actual account creation from asking the user for more information, creating for them an extra incentive to actually go through with this process ("Oh man why do I need to provide my name, let's not sign up" vs "Oh well, I have already registered and given them an email might as well go through with it")


If you would prefer to have them in one step, then providing what code you have already would help us provide better feedback

I am using the HMAC workflow and extended the registrationform, then overwrite the save method to also save the fields that you want to add. Don't forget to add to override the views and make them your new form.

from registration.forms import RegistrationForm
class RegisterForm(RegistrationForm):
    first_name = models.CharField()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM