2010-04-02 67 views

回答

4

做到這一點的一種方法是編寫自己的評論表單,它繼承了django.contrib.comments.forms.CommentForm並重寫了它的get_comment_create_data函數。警告:此代碼未經測試。

from django.contrib.comments.forms import CommentForm 

class MyCommentForm(CommentForm): 
    def get_comment_create_data(self): 
     data = super(MyCommentForm, self).get_comment_create_data() 
     data['is_public'] = False 
     return data 

你會再勾這種形式進入評論系統在本節 http://docs.djangoproject.com/en/dev/ref/contrib/comments/custom/

+0

我用這段代碼做類似的事情;有效。一個挑剔的,字典不是一個變量的最佳名稱,因爲它覆蓋了內建。我用數據代替。 – 2011-08-30 19:39:16

+0

是的,這是一個很好的觀點。我將進行編輯。 – 2011-08-30 20:25:25