Error when using Django SVN version
I've written some code that works fine when I use Django 1.1, but raises an exception when I use the SVN version:
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 开发者_C百科= _("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')
What's the problem?
It's saying error_message was an unexpected keyword argument. Try error_messages instead: http://docs.djangoproject.com/en/dev/ref/forms/fields/#error-messages
Error message passed from one error message to un unlimited number and 's' was added. Error messages are not expected to be added as a dictionary, not a string.
精彩评论