Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何向django注册redux添加额外字段_Python_Django_Registration - Fatal编程技术网

Python 如何向django注册redux添加额外字段

Python 如何向django注册redux添加额外字段,python,django,registration,Python,Django,Registration,我试图向django registration redux添加额外字段,但似乎无法使其正常工作,我以前见过有人问过这个问题,但它只是针对django registration而不是django registration redux提出的,这是不同的。如果有人能告诉我该怎么做,那就太好了。到目前为止,我定义了一个模型和形式,如您在下面看到的。感谢您的帮助,谢谢 另外,我的模型正在管理员页面中注册,但是它不会显示在注册页面上 模型- from django.db import models from

我试图向django registration redux添加额外字段,但似乎无法使其正常工作,我以前见过有人问过这个问题,但它只是针对django registration而不是django registration redux提出的,这是不同的。如果有人能告诉我该怎么做,那就太好了。到目前为止,我定义了一个模型和形式,如您在下面看到的。感谢您的帮助,谢谢

另外,我的模型正在管理员页面中注册,但是它不会显示在注册页面上

模型-

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)
答复:

将此添加到url.py-

url(r'accounts/register/$', RegistrationView.as_view(form_class=EmployerForm), name='registration_register'),