Search code examples
djangodjango-formsdjango-comments

Django Comments: Want to remove user URL, not expand the model. How to?


I'm totally understanding the documentation on expanding the Comments app in Django, and really would like to stick with the automatic functionality but...

In the current app, I have absolutely no use for an "URL" to be submitted along with a comment.

Being minimally invasive of the default setup, how can I prevent this field from showing up with the comment form?

Using Django 1, or Trunk, and as many generic/built-ins as possible (generic views, default comments set up, etc. I have only a single generic view wrapper so far).


Solution

  • This is well documented under customizing the comments framework.

    All your app will use is get_form, returning a subclass of the CommentForm with the url field popped. Something like:

    class NoURLCommentForm(CommentForm):
        """
        A comment form which matches the default djanago.contrib.comments one, but
        doesn't have a URL field.
    
        """
    NoURLCommentForm.base_fields.pop('url')