A user with no email can't post a comment using Django's comments framework

后端 未结 1 1335
花落未央
花落未央 2021-01-14 10:34

I have overrode the comments framework\'s form.html template with my own

{% load comments i18n %}
相关标签:
1条回答
  • 2021-01-14 11:16

    Well, you can use the customization documentation to create a custom app that handles comments from comments framework. You should set COMMENTS_APP = 'my_comment_app' in your settings file and specify a get_form() method in your app's __init__.py which should return your custom form.

    The custom form should be based on contrib.comments.forms.CommentForm and should look something like that:

    class CustomForm(comment_forms.CommentForm):
        def __init__(*args, **kwargs):
            super(CustomFors, self).__init__(*args, **kwargs)
            self.fields["email"].required = False
    

    preview.html is rendered because the form contains errors (emai is required, but user doesn't have it and so it's not populated). If there are no errors - preview won't be shown.

    0 讨论(0)
提交回复
热议问题