<p>我编写了一些代码,在使用Django 1.1时运行良好,但在使用SVN版本时引发了一个异常:</p>
<pre><code>class TribeForm(forms.ModelForm):
slug = forms.SlugField(max_length=20,
help_text = _("a short version of the name consisting only of letters, numbers, underscores and hyphens."),
error_message = _("This value must contain only letters, numbers, underscores and hyphens.")
)
def clean_slug(self):
if Tribe.objects.filter(slug__iexact=self.cleaned_data["slug"]).count() > 0:
raise forms.ValidationError(_("A tribe already exists with that slug."))
return self.cleaned_data["slug"].lower()
def clean_name(self):
if Tribe.objects.filter(name__iexact=self.cleaned_data["name"]).count() > 0:
raise forms.ValidationError(_("A tribe already exists with that name."))
return self.cleaned_data["name"]
class Meta:
model = Tribe
fields = ('name', 'slug', 'description')
</code></pre>
<p>有什么问题吗?你知道吗</p>