Sei. M. Sei. M. - 2 years ago 349
Python Question

How to add first name and last name to Django-registeration-redux registeration form?

I'm using Django-redux but the registeration form only accepts username, email and password. However, I also want to accept first name and last name and also fields from other models like profile pic and city.. I could only find this question: Adding first name and last name to Django-Registration and it's not answered.

This is in my

url(r'^', include('registration.backends.simple.urls')),

and this is in my template:

{{ form.as_p }}

I also want to add this form to the registration form:

class UserProfileForm(forms.ModelForm):
class Meta:
model = UserProfile
fields = ('profilepic', 'city')

Thank you.

Answer Source

Step 1. Add your field in models (

firstname = models.CharField(max_length=255)
lastname = models.CharField(max_length=255)

Step 2. Delete your migration folder and delete tables from database

Step3. use make migration command and then migrate your project.

Hope its solve your problem.

Or you use this..

new_user = User.objects.create_user(username, email, password)
new_user.is_active = False
new_user.first_name = first_name
new_user.last_name = last_name
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download