arthurk / django-disqus Goto Github PK
View Code? Open in Web Editor NEWIntegrates DISQUS into Django
Home Page: http://django-disqus.readthedocs.org/
License: BSD 3-Clause "New" or "Revised" License
Integrates DISQUS into Django
Home Page: http://django-disqus.readthedocs.org/
License: BSD 3-Clause "New" or "Revised" License
I've done everything according to the tutorial from the documentation but yet django-disqus doesn't work. This error appears TemplateSyntaxError -> Invalid block tag: 'disqus_recent_comments'.
Here is the HTML:
And here is the settings.py file:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'blog',
'disqus',
'endless_pagination',
)
DISQUS_API_KEY = 'bKcdgu77D90Ocq7jDOUxPmQbeEgo2TwdaCwuoCKyUStVN17kmfDqq3JxVW1sPA1e'
DISQUS_WEBSITE_SHORTNAME = 'orcage'
I've installed django-disqus by using pip: sudo pip install django-disqus
It appears that django-disqus is in the PYTHON_PATH:
'/usr/local/lib/python2.7/dist-packages/django_disqus-0.4.1-py2.7.egg',
Note: Other Templatetags such as {% disqus_show_comments %} work.
It appears as though API version 1.1 has been discontinued, and there's no way for a new user to get their API key. The endpoint that made this possible now returns a 404.
This library needs to be updated to support the current API (version 3), which instead uses OAuth 2.
This is the output of the command:
Exporting 3 comment(s)
Exporting comment 'Alain M. Lafon: Hiho,
you should check out the way you link on ...'
Exporting comment 'Alain M. Lafon: No links allowed? Well.. good to prevent spam, bad...'
Exporting comment 'Gregor Müllegger: You're right. I fixed it and the link should work ...'
Traceback (most recent call last):
File "bin/django", line 33, in <module>
djangorecipe.manage.main('website.settings')
File "/srv/gremu/eggs/djangorecipe-0.20-py2.5.egg/djangorecipe/manage.py", line 16, in main
management.execute_manager(mod)
File "/srv/gremu/parts/django/django/core/management/__init__.py", line 362, in execute_manager
utility.execute()
File "/srv/gremu/parts/django/django/core/management/__init__.py", line 303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/srv/gremu/parts/django/django/core/management/base.py", line 195, in run_from_argv
self.execute(*args, **options.__dict__)
File "/srv/gremu/parts/django/django/core/management/base.py", line 222, in execute
output = self.handle(*args, **options)
File "/srv/gremu/eggs/django_disqus-0.3-py2.5.egg/disqus/management/commands/disqus_export.py", line 98, in handle
created_at=comment.submit_date.strftime('%Y-%m-%dT%H:%M'))
File "/srv/gremu/eggs/django_disqus-0.3-py2.5.egg/disqus/api.py", line 53, in call_method
return self.call(attr, **kwargs)
File "/srv/gremu/eggs/django_disqus-0.3-py2.5.egg/disqus/api.py", line 77, in call
request = self._get_request(url, self.METHODS[method], **params)
File "/srv/gremu/eggs/django_disqus-0.3-py2.5.egg/disqus/api.py", line 67, in _get_request
request = urllib2.Request(request_url, urlencode(params))
File "/usr/lib/python2.5/urllib.py", line 1250, in urlencode
v = quote_plus(str(v))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 8: ordinal not in range(128)
A --dry-run
is working without any problems. The non ascii character is the
german "ü" in my last name.
Does django-disqus support Disqus' single sign on functionality? That would be rad if it did.
When installing using either pip or easy_install, you get the following error:
Searching for django-disqus
Reading http://pypi.python.org/simple/django-disqus/
Reading http://github.com/arthurk/django-disqus
Reading http://arthurk.github.com/django-disqus/
Reading http://django-disqus.readthedocs.org/
Best match: django-disqus 0.4
Downloading http://pypi.python.org/packages/source/d/django-disqus/django-disqus-0.4.tar.gz#md5=97d09e7f72b0fea3f2c186b3
4ec0e48c
Processing django-disqus-0.4.tar.gz
Running django-disqus-0.4\setup.py -q bdist_egg --dist-dir c:\users\martin\appdata\local\temp\easy_install-hffv0_\django
-disqus-0.4\egg-dist-tmp-l4_tgk
Traceback (most recent call last):
File "C:\Python26\Scripts\easy_install-script.py", line 8, in
load_entry_point('setuptools==0.6c11', 'console_scripts', 'easy_install')()
File "C:\Python26\lib\site-packages\setuptools\command\easy_install.py", line 1712, in main
with_ei_usage(lambda:
File "C:\Python26\lib\site-packages\setuptools\command\easy_install.py", line 1700, in with_ei_usage
return f()
File "C:\Python26\lib\site-packages\setuptools\command\easy_install.py", line 1716, in
distclass=DistributionWithoutHelpCommands, **kw
File "C:\Python26\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Python26\lib\distutils\dist.py", line 975, in run_commands
self.run_command(cmd)
File "C:\Python26\lib\distutils\dist.py", line 995, in run_command
cmd_obj.run()
File "C:\Python26\lib\site-packages\setuptools\command\easy_install.py", line 211, in run
self.easy_install(spec, not self.no_deps)
File "C:\Python26\lib\site-packages\setuptools\command\easy_install.py", line 446, in easy_install
return self.install_item(spec, dist.location, tmpdir, deps)
File "C:\Python26\lib\site-packages\setuptools\command\easy_install.py", line 476, in install_item
dists = self.install_eggs(spec, download, tmpdir)
File "C:\Python26\lib\site-packages\setuptools\command\easy_install.py", line 655, in install_eggs
return self.build_and_install(setup_script, setup_base)
File "C:\Python26\lib\site-packages\setuptools\command\easy_install.py", line 930, in build_and_install
self.run_setup(setup_script, setup_base, args)
File "C:\Python26\lib\site-packages\setuptools\command\easy_install.py", line 919, in run_setup
run_setup(setup_script, args)
File "C:\Python26\lib\site-packages\setuptools\sandbox.py", line 62, in run_setup
lambda: execfile(
File "C:\Python26\lib\site-packages\setuptools\sandbox.py", line 105, in run
return func()
File "C:\Python26\lib\site-packages\setuptools\sandbox.py", line 64, in
{'file':setup_script, 'name':'main'}
File "setup.py", line 21, in
'compressor.conf',
File "C:\Python26\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Python26\lib\distutils\dist.py", line 975, in run_commands
self.run_command(cmd)
File "C:\Python26\lib\distutils\dist.py", line 995, in run_command
cmd_obj.run()
File "C:\Python26\lib\site-packages\setuptools\command\bdist_egg.py", line 167, in run
self.run_command("egg_info")
File "C:\Python26\lib\distutils\cmd.py", line 333, in run_command
self.distribution.run_command(command)
File "C:\Python26\lib\distutils\dist.py", line 995, in run_command
cmd_obj.run()
File "C:\Python26\lib\site-packages\setuptools\command\egg_info.py", line 177, in run
self.find_sources()
File "C:\Python26\lib\site-packages\setuptools\command\egg_info.py", line 252, in find_sources
mm.run()
File "C:\Python26\lib\site-packages\setuptools\command\egg_info.py", line 308, in run
self.read_template()
File "C:\Python26\lib\site-packages\setuptools\command\sdist.py", line 157, in read_template
_sdist.read_template(self)
File "C:\Python26\lib\distutils\command\sdist.py", line 336, in read_template
self.filelist.process_template_line(line)
File "C:\Python26\lib\distutils\filelist.py", line 129, in process_template_line
(action, patterns, dir, dir_pattern) = self._parse_template_line(line)
File "C:\Python26\lib\distutils\filelist.py", line 112, in _parse_template_line
dir_pattern = convert_path(words[1])
File "C:\Python26\lib\distutils\util.py", line 201, in convert_path
raise ValueError, "path '%s' cannot end with '/'" % pathname
ValueError: path 'example/' cannot end with '/'
I'd like to make use of the disqus_recent_comments tag but the latest version of django-disqus available on pypi is v0.4.1 and it does not include this tag. Would it be possible to update the version available on pypi so I can make use of this tag without rewriting it myself?
Need to update the link to getting an API key from Disqus
to
http://disqus.com/api/applications/
I try to run disqus_export but it causes HTTP Error 400: BAD REQUEST.
Perhaps it relates to Oauth authorization. Does django-disqus support Oauth ?
This is call stack:
Exporting 165 comment(s)
{"message":"Key could not be converted to UserKey object","code":"input-invalid","succeeded":false}
Traceback (most recent call last):
File "manage.py", line 14, in
execute_manager(settings)
File "/usr/lib/python2.6/site-packages/django/core/management/init.py", line 459, in execute_manager
utility.execute()
File "/usr/lib/python2.6/site-packages/django/core/management/init.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(_args, *_options.dict)
File "/usr/lib/python2.6/site-packages/django/core/management/base.py", line 232, in execute
output = self.handle(_args, *_options)
File "/usr/lib/python2.6/site-packages/disqus/management/commands/disqus_export.py", line 80, in handle
forum_list = client.get_forum_list(user_api_key=settings.DISQUS_API_KEY)
File "/usr/lib/python2.6/site-packages/disqus/api.py", line 53, in call_method
return self.call(attr, *_kwargs)
File "/usr/lib/python2.6/site-packages/disqus/api.py", line 79, in call
response = urllib2.urlopen(request)
File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib64/python2.6/urllib2.py", line 397, in open
response = meth(req, response)
File "/usr/lib64/python2.6/urllib2.py", line 510, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib64/python2.6/urllib2.py", line 435, in error
return self._call_chain(_args)
File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
result = func(*args)
File "/usr/lib64/python2.6/urllib2.py", line 518, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 400: BAD REQUEST
You should rather use protocol relative URL as people are having problems with integrating this package into Django projects served via HTTPS.
See http://stackoverflow.com/questions/24160223/itegrating-django-disqus-on-a-https-site
After an upgrade to Django 1.6, I get the following DeprecationWarning
from Django when using django-disqus
:
2013-11-13 11:20:12,740 WARNING /path/to/site-packages/disqus/__init__.py:5: DeprecationWarning: django.utils.simplejson is deprecated; use json instead.
from django.utils import simplejson as json
Using the systems Python json
library fixes this. Pretty simple fix.
On my site comments is not showing.
for API key I use public key.
Here i wrote more about issue on discuss disqus. https://disqus.com/home/channel/discussdisqus/discussion/channel-discussdisqus/django_disqus/
Also here is my repo:
https://bitbucket.org/ivan_bagaric/putovanja.net/src
I know this has been asked before, but I think from solutions I've seen that my case may be a bit different. I have followed the instructions and am still getting all comments displayed on all posts.
The links to each comment in the disqus moderation site are of the format: http://127.0.0.1:8009/post#comment-1617310015
But, they should be .../post/14/#...
i.e. they should have a post id in there.
I have this:
{% load disqus_tags %}
{% set_disqus_url "127.0.0.1:8009/post/" post.id "/" %}
{% set_disqus_identifier post.id %}
{% disqus_show_comments %}
The resulting javascript looks like:
var disqus_identifier = "12";
var disqus_url = "127.0.0.1:8009/post/12/";
I am also sure I have the shortname correct and have the site in the site id
Any ideas would be greatly appreciated.
Hiya!
I'm trying to deploy django-disqus on my http://gour-nitai.com (mingus) 'site', but the comment form is (somehow) not shown...
I've the following in my base.html template:
{% disqus_show_comments %}
View Comments
{% disqus_num_replies %}
{% disqus_recent_comments %}
but the comment form is not shown.
I've registered the site at disqus.com and have DISQUS_API_KEY & DISQUS_WEBSITE_SHORTNAME in my local_settings.py.
What am I missing?
Sincerely,
Gour
Hello
I have a problem with disqus_export command: default verbosity is not set and there is no verbosity option. Am I missing something? I use version 0.3.4.
Regards
Magda
$ python manage.py disqus_export -d Traceback (most recent call last): File "manage.py", line 11, in 0.3.4 execute_manager(settings) File "/home/dev/www/.python/lib/python2.5/site-packages/django/core/management/__init__.py", line 340, in execute_manager utility.execute() File "/home/dev/www/.python/lib/python2.5/site-packages/django/core/management/__init__.py", line 295, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/dev/www/.python/lib/python2.5/site-packages/django/core/management/base.py", line 192, in run_from_argv self.execute(*args, **options.__dict__) File "/home/dev/www/.python/lib/python2.5/site-packages/django/core/management/base.py", line 219, in execute output = self.handle(*args, **options) File "/home/dev/www/.python/lib/python2.5/site-packages/django_disqus-0.3.4-py2.5.egg/disqus/management/commands/disqus_export.py", line 56, in handle verbosity = int(options.get('verbosity')) TypeError: int() argument must be a string or a number, not 'NoneType'
$ python manage.py disqus_export -d --verbosity=1 Usage: manage.py disqus_export [options] Export comments from contrib.comments to DISQUS manage.py: error: no such option: --verbosity
I was getting a HTTP 400 Bad Request when exporting my django.contrib.comments. This was because the export command was not properly assigning the default value when the contrib model returned an empty string for User and User Email.
I fixed it by modifying the disqus_export.py file to perform the following tests:
author_email = '[email protected]' if not author_email else author_email
author_name = 'nobody' if not author_name else author_name
that segment of code then looked like:
# name and email are optional in contrib.comments but required
# in DISQUS. If they are not set, dummy values will be used
author_email = comment.userinfo.get('email', '')
author_email = '[email protected]' if not author_email else author_email
author_name = comment.userinfo.get('name', '')
author_name = 'nobody' if not author_name else author_name
client.create_post(
forum_api_key=forum_api_key,
thread_id=thread['id'],
message=comment.comment.encode('utf-8'),
author_name=author_name.encode('utf-8'),
author_email=author_email.encode('utf-8'),
author_url=comment.userinfo.get('url', ''),
created_at=comment.submit_date.strftime('%Y-%m-%dT%H:%M'))
if state_file is not None:
self._save_state(state_file, comment.pk)
Looks like django-disqus
lacks support for setting thread id that is also needed according to https://help.disqus.com/customer/portal/articles/662547-why-are-the-same-comments-showing-up-on-multiple-pages-
Or is it something I missed?
Hey, I was looking for a commenting system solution for a Django blog and it was quite troublesome to engineer one from ground zero within Django. So I found out that I could use disqus. I saw your extension and figured it was the best solution. Turns out it is no longer needed, since you can't get an API key without a pro upgrade on disqus, and it is easier to use their universal code JS snippet to embed the commenting system easily.
For anyone curious here is what I did. Create an account at disqus, select 'I want to use it in my site', add your sites shortname and domain (in my case Im devving locally on ubuntu VM and used my dev domain I created 'djang0.me' for my test django blog). Go to installation instructions, select 'universal code' at bottom and copy the code. I decided to use an include disqus block in my django blogs Post template, which is very nice:
# blog/includes/disqus.html
{% block disqus %}
<div class="container">
<div class="row">
<a class="btn btn-default arches" role="button" data-toggle="collapse" href="#dcomments" aria-expanded="true" style="width: 120px; display: block; margin: 0 auto; margin-top: 20vh;"> <h4 class="text-success"> Comments » </h4> </a>
<div class="col-md-6 col-md-offset-3">
<div class="panel collapse stucco" id="dcomments" style="margin-top: 10vh;">
<div id="disqus_thread"></div>
</div>
</div>
</div>
</div>
<script>
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables*/
/*
var disqus_config = function () {
this.page.url = djang0.me; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = sldtech; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://sldtech.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<script id="dsq-count-scr" src="//sldtech.disqus.com/count.js" async></script>
{% endblock %}
# blog/post.html
{% extends "blog/blogbase.html" %}
{% block body %}
<div class="container">
<div class="col-md-12 text-center">
<h6 class="pull-right"> on {{ post.date }} </h6> <br>
<h3> {{ post.title }} </h3> <br>
<img src="{% if post.image %} {{ post.image.url }} {% endif %}" class="img-responsive center-block" align="left" alt="">
<p> {{ post.body|safe|linebreaks }} </p>
</div>
</div>
{% include 'blog/includes/disqus.html' %}
{% block disqus %}{% endblock %}
{% endblock %}
Only thing Im a little confused about is, they recommend uncommenting the variables:
//this.page.url = djang0.me; // Replace PAGE_URL with your page's canonical URL variable
//this.page.identifier = ; // Replace PAGE_IDENTIFIER with your page's unique identifier
Would you know what should I use for this.page.identifier in a django blog, if anything?
I'd like to be able to include the Disqus code over https. Disqus apparently supports this.
http://help.disqus.com/customer/portal/articles/542119-can-disqus-be-loaded-via-https-
Update/Resolution: In case {% with %}
is used {% disqus_show_comments %}
must be placed before the closing {% endwith %}
. Looks like it's worth a mention in the docs. Close it if you think otherwise.
Older comment:
This line does nothing:
Django 1.8.18
django-disqus 0.5
Python 3.4
I've set it up long ago and didn't check it. It was working without this config. At least we thought it was until we found out that comments are published on wrong pages and wrong links were formed by Disqus.
I have a recipe
model and i need create a view for most commented recipes, i'm using django-disqus
for handling recipe's comments, but i don't know how can i order the queryset by the recipe's comment number.
class PopRecipeListView(GlobalQueryMixin, ListView):
model = Recipe
context_object_name = "recipe_list"
template_name = 'recipe/recipe_top_list.html'
def get_queryset(self):
qs = super(PopRecipeListView, self).get_queryset()
if qs:
qs = qs.extra(
select={
'comments': # get comment numbers
}
).filter(shared=True).order_by('-rate')[:20]
return qs
Question here.
What's the properly way?
I'm having this same problem:
I followed the docs and it makes no mention of what to do.
When I go to my disqus dashboard, it says my comments were all posted on "example.com".
How do I make django-disqus aware of the current article so it can tell them apart?
Thanks,
Shige
I think the disqus js files should be served from the same protocol as the page they are rendered on (https://disqus.com/.. if the page is served off https). This will reduce the mixed content warnings on most browsers.
I am willing to generate a patch for this if you are fine including it.
When using pip to install. It installed a version where tag disqus_show_recent_comments does not exist. I guess it is installing the develop branch rather than the master?
I had some strange validation errors on my Disqus enabled site (screenshot), and I found out that the Disqus JavaScript code was causing trouble.
I've made a fix based on how most other scripts do this, and posted it on Gistie.
Hello!
I have successfully installed and integrated django-disqus.
My site is multilanguage so the locale change from django doesnt affect on embedded disqus code.
And it is turkish by default :)
disqus_developer
var is deprecated.
We can remove {% set_disqus_developer 1 %}
tag. There are additional shortnames
for that goal.
The code produced by templatetag does not seem to work, while example from disqus website does work.
i just installed your library and got the above error, it is related to the following lines:
from django.utils.six.moves.urllib.parse import urlencode
from django.utils.six.moves.urllib.error import URLError
from django.utils.six.moves.urllib.request import (
ProxyHandler,
Request,
urlopen,
build_opener,
install_opener
)
Can you fix this to support django 1.4.x versions?
Hello all,
i follow the official documentation to install this package, but anytime i get this error. If i try from the shell of the project i can import disqus but not when import it in settings.APP!!
Django 1.4.7
[Tue Apr 14 06:12:19 2015] [error] [client 2.229.240.11] ImportError: No module named disqus
thanks in advance
Marco
I installed and configured django-disqus according to instructions in the documentation but somehow django view which I included disqus template tags gives the error below.
Django Version: 1.7.5
Exception Type: KeyError
Exception Value:
'request'
Additionally, line with {% disqus_dev %}
highlighted in the error log.
Am I missing something or is that an issue?
I'm having some problems with encodings when i use disqus_show_comments tag on the template.
When i have special characters on my title causes error on get_config. The generation of output causes that error, my suggestion is to not use the format to create the output:
output = ['\tvar %s = "%s";' % (item, context[item]) for item in conf_vars \
if item in context]
Django Disqus works fine on my site when delivered over http, but when I switched my site over to https, comments no longer load.
It appears that the Disqus code is being loaded with a hard-coded http://
:
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
This should be replaced by a protocol-relative prefix, i.e.
'//' + disqus_shortname + '.disqus.com/embed.js';
This will cause the script to be loaded over http if the site is accessed via http, or https if loaded over https.
Has there been any thought to add a feature to pull a users most recent comments? I am creating a "friends" element on the application I am building and I would like to be able to add friends most recent comments to their friends feed.
Simple json is depreciated beyond django 1.5 and is recommended to use json.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.