Question

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
Était-ce utile?

La solution

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.

Autres conseils

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top