我正在尝试从基类 UserCreationForm 创建注册表单,在 django 中添加电子邮件字段。代码如下
表格.py
class signup(UserCreationForm):
email=forms.EmailField()
class Meta:
model=User
fields=('username','email','password1','password2')
def save(self, commit=True):
user = super(UserCreationForm, self).save(commit=False)
user.email=(self.cleaned_data["email"])
if commit:
user.save()
return user
视图.py
def signup(request):
if request.method=='POST':
form=signup(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/accounts/rgsuc')
args={}
args.update(csrf(request))
args['form']=signup()
return render_to_response('register.html',args)
网址.py
url(r'^accounts/signup',signup),
错误
\view.py in signup, line 75
signup() takes exactly 1 argument (0 given)
我在这里尝试了这个视频教程