使用Django SVN版本时出错

时间:2010-02-01 07:39:16

标签: python django

我编写了一些在使用Django 1.1时工作正常但在使用SVN版本时引发异常的代码:

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')

有什么问题?

2 个答案:

答案 0 :(得分:0)

这就是说error_message是一个意外的关键字参数。请尝试使用error_messages:http://docs.djangoproject.com/en/dev/ref/forms/fields/#error-messages

答案 1 :(得分:0)

错误消息从一条错误消息传递到无限制号码' s'加入。错误消息不会被添加为字典,而不是字符串。