【发布时间】:2010-10-25 11:55:11
【问题描述】:
我正试图抓住 Django。我在 Eclipse 上使用 Pydev。我写了一个简单的注册页面,但我无法开始工作。 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)
...
【问题讨论】:
-
+1 作为问题标题。
-
你试过运行代码吗?只是 pydev 抱怨还是根本不起作用?
-
它可以工作,但除非我把代码拿出来,否则它不会让我在 pydev 上调试。
标签: python django authentication django-models pydev