Easily integrate DISQUS comments into your website.
- Export django.contrib.comments to DISQUS
- Dump DISQUS into local JSON file
- Templatetags to ease the integration
- Django 1.x
- Optional: Mock 0.5.0 (if you want to run the unit tests)
easy_install django-disqus
or clone the git repo and runpython setup.py install
.- Add
disqus
to yourINSTALLED_APPS
setting. - Add
DISQUS_API_KEY
andDISQUS_WEBSITE_SHORTNAME
to your settings. You can get your API key here. The shortname of your site can be found in the right sidebar ("My Websites") on the DISQUS homepage.
Example settings.py:
INSTALLED_APPS = (
...
'django.contrib.comments',
'disqus',
)
DISQUS_API_KEY = 'FOOBARFOOBARFOOBARFOOBARFOOBARF'
DISQUS_WEBSITE_SHORTNAME = 'foobar'
The disqus-export
command exports comments from django.contrib.comments to
DISQUS.
When exporting comments, make sure you have the domain of your Site set. Also
the Model to which the comments are associated needs a get_absolute_url()
method which returns the absolute url to the page the comments should
appear on.
Threaded comments are not supported.
Options:
- -d/--dry-run: Does not export any comments, but merely outputs the comments which would have been exported
- -v/--verbosity: Output verbosity level; 0=minimal output, 1=normal output
The disqus-dumpdata
command dumps DISQUS comments into a local JSON file.
Options:
- --indent: Specifies the indent level to use when pretty-printing output
In order to get comments working on a local development server you need to
include this templatetag in your website's <head>
:
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>fooar</title>
{% disqus_dev %}
</head>
If the DEBUG
setting is set to True
this sets the disqus_developer
variable to 1
to disable url validation. It also sets disqus_url
to the current Site's domain. Without this, it wouldn't be possible to display
the comment form locally.
Returns the JavaScript necessary to replace all permalinks which have the
#disqus_thread
anchor with the comment count for that url.
Example:
<a href="{{ object.get_absolute_url }}#disqus_thread">View Comments</a>
{% disqus_num_replies %}
Returns the JavaScript necessary to display the comment form and comments.
Example:
{% disqus_show_comments %}