我是django的新人。我试着做一个简单的电子邮件联系表单,通过简单的验证。 我遇到了一个我无法解决的错误。 这个表单.py以及视图.py在同一目录中(project中没有内部应用程序)
表单.py
from django import forms
class ContactForm(forms.Form):
subject = forms.CharField(max_length=100)
email = forms.EmailField(label='Your e-mail address')
message = forms.CharField(widget=forms.Textarea)
def clean_message(self):
new_message = self.cleaned_data['message']
num_words = len(new_message.spilt(' '))
if num_words < 4:
raise forms.ValidationError('Not enough words!')
return new_message
视图.py
^{pr2}$我的错误:
AttributeError at /contact/
'unicode' object has no attribute 'spilt'
Request Method: POST
Request URL: http://127.0.0.1:8000/contact/
Django Version: 1.7.1
Exception Type: AttributeError
Exception Value:
'unicode' object has no attribute 'spilt'
Exception Location: /Users/alonbond/django_apps/gadi/gadi/forms.py in clean_message, line 10
有什么帮助吗?谢谢!
您编写了}。在
spilt
,而不是{相关问题 更多 >
编程相关推荐