0

我使用 django 中的默认评论表单作为文档。但是像“name”、“url”这样的标签不适合我的需要。我需要它们变成中文。如何更改这些标签以及如何使用评论自定义表单框架?请帮助我。非常感谢。 我博客的评论页面

我自定义了表格,但它不起作用。

form.py:
class CommentFormmodels(CommentForm):
    name          = forms.CharField(label=("姓名"), max_length=50)
    email         = forms.EmailField(label=("Email address"))
    url           = forms.URLField(label=("个人站点")`enter code here`, required=False)
    comment       = forms.CharField(label=('评论'), widget=forms.Textarea,
        max_length=COMMENT_MAX_LENGTH)
    def get_comment_model(self):
        return CommentForm
    def get_comment_create_data(self):
        data = super(CommentFormmodels,self).get_comment_create_data()
        data['name']=self.cleaned_data['name']
        data['email'] = self.cleaned_data['email']
        data['url'] = self.cleaned_data['url']
        data['comment'] = self.cleaned_data['comment']
        return data
__init__.py:
from comment.forms import CommentFormmodels 

def get_fom():
    return CommentFormmodels
4

2 回答 2

1

https://docs.djangoproject.com/en/1.4/ref/contrib/comments/custom/

您需要创建您的评论应用程序,从 CommentForm 创建新表单并更改其中的标签。

于 2012-12-25T15:50:08.313 回答
0

看看标签部分: https ://docs.djangoproject.com/en/dev/ref/forms/fields/#label

于 2012-12-25T15:38:06.440 回答