0

我有一个定义如下的表格:

from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm as DjangoUserCreationForm

class UserEmailForm(DjangoUserCreationForm):
    email = forms.EmailField(required=True)

    class Meta:
        model = User
        fields = ("email",)

    def save(self, commit=True):
        user = super(UserEmailForm, self).save(commit=False)
        user.email = self.cleaned_data["email"]
        if commit:
            user.save()
        return user

但是当我尝试显示表单时,它显示了四个字段,用户名、电子邮件、密码1、密码2

4

1 回答 1

0

这些字段在 UserCreationForm 表单中定义,Meta#fields 不会影响它们

于 2013-01-05T20:30:30.927 回答