Answer the question
In order to leave comments, you need to log in
How to add another field during registration?
Hello.
I want to add one more field when registering a user, namely phone.
models.py
from django.db import models
from django.contrib.auth.models import User
class CustomUserPhone(models.Model):
user = models.ForeignKey(User)
phone = models.CharField(max_length=25)
urlpatterns = patterns('',
url(r'^$',
TemplateView.as_view(template_name='index.html'),
name='index'),
url(r'^registration/$',
RegistrationView.as_view(form_class=RegistrationFormUniqueEmail),
name='registration_register'),
url(r'^accounts/',
include('registration.backends.default.urls')),
url(r'^profile/',
TemplateView.as_view(template_name='profile.html'),
name='profile'),
url(r'^login/',
'django.contrib.auth.views.login',
name='login'),
url(r'^logout/',
'django.contrib.auth.views.logout',
name='logout')
)
Answer the question
In order to leave comments, you need to log in
Reload the RegistrationFormUniqueEmail form, add your field there and the logic for saving the CustomUserPhone model.
In general, it would be better to make a custom user model and simply add this field there, and not to fence one-to-one.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question