문제

I use the default comment form in django as the document.But the tages like "name","url" aren`t suit my need.I need them become chinese.How can I change these tages and How to custom form with the comment framework?Please help me.Thanks a lot. The comment page of my blog

And I custom the form but it doesn't work.

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
도움이 되었습니까?

해결책

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

You need to create your comments app, create new form from CommentForm and change labels in it.

다른 팁

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top