我正在尝试向django-registration-redux添加额外的字段,但似乎无法使其正常工作,我已经看过这个问题之前已被问过,但它只被要求django-registration而不是django-registration-redux哪个是不同的。如果有人可以指导我做什么,这将是伟大的。到目前为止,我已经定义了一个模型和表单,如下所示。感谢任何帮助,谢谢!
P.S。我的模型正在管理页面中注册,但它不会显示在注册页面上。
模型 -
from django.db import models
from django.contrib.auth.models import User
class EmployerProfile(models.Model):
user = models.OneToOneField(User, unique=True)
home_number = models.IntegerField(max_length=12)
mobile_number = models.IntegerField(max_length=12)
business_name = models.CharField(max_length=50)
business_address_number = models.IntegerField()
business_address_street = models.CharField(max_length=50)
business_address_region = models.CharField(max_length=50)
business_address_suburb = models.CharField(max_length=50)
business_address_postcode = models.IntegerField()
business_industry = models.CharField(max_length=50)
def __unicode__(self):
return self.business_name
表格 -
from django import forms
from registration.forms import RegistrationForm
class EmployerForm(RegistrationForm):
region_choice = (
('1', 'Auckland'),
('2', 'Wellington'),
('3', 'Christchurch')
)
suburb_choice = (
('1', 'Glendowie'),
('2', 'Kohimarama'),
('3', 'Mission Bay')
)
industry_choice = (
('1', 'Restaurant'),
('2', 'IT'),
('3', 'Construction')
)
home_number = forms.IntegerField()
mobile_number = forms.IntegerField()
business_name = forms.CharField()
business_address_number = forms.IntegerField()
business_address_street = forms.CharField()
business_address_region = forms.ChoiceField(choices=region_choice)
business_address_suburb = forms.ChoiceField(choices=suburb_choice)
business_address_postcode = forms.IntegerField()
business_industry = forms.ChoiceField(choices=industry_choice)
答案 0 :(得分:1)
答案:
将此添加到 urls.py -
url(r'accounts/register/$', RegistrationView.as_view(form_class=EmployerForm), name='registration_register'),