python - Add optional fields to django's built-in comments app -
I want to add a thumb and counter thumb as comment areas and I called 'MyComment' in models.py Add two inteferer to a class. And I also use such forms.py:
After that, when I submit a comment, say THUMBS_UP And THUMBS_DOWN are required Not. How do I make them optional, just like the default field "user url"? Import django.contrib.comments.models from
Comment class Mycomment (comment): thumbs_up = Model. Text after the integerField (default = 0) THUMBS_DOWN = models.IntegerField (default = 0)
you
class MyCommentForm: CommentForm: THUMBS_UP = forms.IntegerField (expected = false) THUMBS_DOWN = forms.IntegerField ( Expected = false)
and get_comment_create_data Take
def get_comment_create_data (auto): data = super (MyCommentForm, itself) .get_comment_create_data () data ['thumbs_up'] = Self.cleaned_data.get ('thumbs_up', 0) data ['Thumbs_down'] = self.cleaned_data.get ('thumbs_down', 0) Return Data
Comments
Post a Comment