AttributeError:'module'对象没有属性'EmailInput'

use*_*969 1 python django

AttributeError当我尝试在WebFaction生产服务器上运行以下代码时,我得到一个例外(它在开发中工作):

#forms.py

class UserRegistrationForm(forms.ModelForm):
    full_name = forms.CharField(widget=forms.TextInput(attrs={'placeholder':'Your full name'}))
    email = forms.CharField(widget=forms.EmailInput(attrs={'placeholder':'Activation email will be sent'}))
    password = forms.CharField(widget=forms.PasswordInput)
    meal_package = forms.ModelChoiceField(queryset=Package.objects.all(), widget=forms.RadioSelect(), empty_label=None)
    mobile = forms.CharField(widget=forms.TextInput(attrs={'placeholder':'You will recieve a call on this number'}))
    area_name = forms.CharField(widget=forms.TextInput(attrs={'placeholder':'Name of your area'}))
    building_name = forms.CharField(widget=forms.TextInput(attrs={'placeholder':'Name of your building'}))
    room_no = forms.CharField(widget=forms.TextInput(attrs={'placeholder':'Your apartment number'}))

    class Meta:
        model = User
        fields = ['full_name', 'email', 'password', 'meal_package' ,'mobile', 'area_name', 'building_name', 'room_no']
Run Code Online (Sandbox Code Playgroud)

这是错误:

  File "/home/hammad/webapps/feastymeals/Feasty-Meals/Users/forms.py", line 27, in <module>
    class UserRegistrationForm(forms.ModelForm):
  File "/home/hammad/webapps/feastymeals/Feasty-Meals/Users/forms.py", line 29, in UserRegistrationForm
    email = forms.CharField(widget=forms.EmailInput(attrs={'placeholder':'Activation email will be sent'}))
AttributeError: 'module' object has no attribute 'EmailInput'
Run Code Online (Sandbox Code Playgroud)

Dan*_*man 5

EmailInput是1.6版中的新属性.您可能需要验证您在代码引发错误的服务器上使用的是1.6版.如果您使用的是旧版本,则无法使用该属性,这可能是因为它可以在一台计算机上运行而不在另一台计算机上运行.