我在试着联系Django .我在Eclipse上使用Pydev.我写了一个简单的注册页面,我不能go 上班.Eclipse抱怨User.DoesNotExist未定义.最有可能的是,我错过了一些微不足道的东西.以下是代码的相关部分:
from django.contrib.auth.models import User
...
class SignUpForm (forms.Form):
...
def clean_username (self):
try:
User.objects.get(username=self.cleaned_data['username'])
except User.DoesNotExist:
return self.cleaned_data['username']
raise forms.ValidationError(USERNAME_ALREADY_IN_USE)
...