Search code examples
djangosubclassing

Doing it right in Django - subclassing instead of hacking


I am using the threadedcomments module and need two changes: - an additional field on the ThreadedComment model - different fields on the form

I know the answer is to subclass but I'm not sure how to go about doing this - where does the code go?


Solution

  • As its not clear from you question. I am assuming you are talking about extending django.contrib.comments .

    Yes you have to subclass it. Create your own application, and all code (extended models, forms, views etc.) goes there.

    Important things, you wont add django.contrib.comments in INSTALLED_APPS list, but add your comment application name(which you inherit from django.contrib.comments).

    Also you would need to add

    COMMENTS_APP = 'my_comment_app'
    

    to your settings.py

    Here is very good example for doing exactly what you want to do.