Introduction¶
django-comments-xtd extends django-contrib-comments framework with:
- Thread support, so comments may be nested
- The maximum thread level can be set up either for all models or on a per app.model basis
- Optional notification of follow-up comments via email
- Mute links on follow-up emails to allow follow-up notification cancellation
- Comment confirmation via email when users are not authenticated
- Comments hit the database only when have been confirmed
- Template tags to list/render the last N comments posted to any given list of app.model pairs
- Comments can be formatted in Markdown, reStructuredText, linebreaks or plain text
- Emails sent through threads (can be disable to allow other solutions, like a Celery app)
Quick start¶
- In your
settings.py:
- Add
django.contrib.commentsanddjango_comments_xtdtoINSTALLED_APPS- Add
COMMENTS_APP = "django_comments_xtd"- Add
COMMENTS_XTD_MAX_THREAD_LEVEL = N, beingNthe maximum level up to which comments can be threaded:
- When N = 0: comments are not nested
- When N = 1: comments can be bested at level 0
- When N = K: comments can be nested up until level K-1
This setting can also be set up on a per
<app>.<model>basis so that you can enable different thread levels for different models. ie: no nested comment for blog posts, up to one thread level for book reviews...Read more about
COMMENTS_XTD_MAX_THREAD_LEVEL_BY_APP_MODELin the Tutorial and see it in action in the multiple demo site in Demo projects.
- Customize your project’s email settings:
EMAIL_HOST = "smtp.mail.com"EMAIL_PORT = "587"EMAIL_HOST_USER = "alias@mail.com"EMAIL_HOST_PASSWORD = "yourpassword"DEFAULT_FROM_EMAIL = "Helpdesk <helpdesk@yourdomain>"
- If you want to allow comments written in markup languages like Markdown or reStructuredText:
- Get the dependencies: django-markup
- And add
django_markuptoINSTALLED_APPS
- Add
url(r'^comments/', include('django_comments_xtd.urls'))to your root URLconf. - Change templates to introduce comments:
- Load the
commentstemplatetag and use their tags (ie: in yourtemplates/app/model_detail.htmltemplate):
{% get_comment_count for object as comment_count %}{% render_comment_list for object %}(usescomments/list.html){% render_comment_form for post %}(usescomments/form.htmlandcomments/preview.html)
- Load the
comments_xtdtemplatetag and use their tags and filter:
{% get_xtdcomment_count as comments_count for blog.story blog.quote %}{% render_last_xtdcomments 5 for blog.story blog.quote using "blog/comment.html" %}{% get_last_xtdcomments 5 as last_comments for blog.story blog.quote %}- Filter render_markup_comment:
{{ comment.comment|render_markup_comment }}. You may want to copy and change the templatecomments/list.htmlfromdjango.contrib.commentsto use this filter.
syncdb,runserver, and- Hit your App’s URL!
- Have questions? Keep reading, and look at the 3 demo sites.