使用Django SVN版本时出错

2024-05-15 00:13:48 发布

您现在位置:Python中文网/ 问答频道 /正文

我编写了一些代码,在使用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')

有什么问题吗?你知道吗


Tags: andofnameselfonlydataformsclass
2条回答

它说错误消息是一个意外的关键字参数。改为尝试错误消息:http://docs.djangoproject.com/en/dev/ref/forms/fields/#error-messages

错误消息从一个错误消息传递到非无限数,并添加了“s”。错误消息不应作为字典而不是字符串添加。你知道吗

相关问题 更多 >

    热门问题