arthurk / django-disqus

Integrates DISQUS into Django

Home Page:http://django-disqus.readthedocs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Django 1.6 Deprecation Warning: django.utils.simplejson is deprecated

robnewman opened this issue · comments

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.

@fadur - Thanks for fixing this. I have uninstalled @arthurk's version and installed your clone. I appreciate you taking the time to clone.

Guess I should leave this issue open until @arthurk actually merges the change that @fadur made back into the version being distributed via pip.

I have just installed django-disqus 0.4.3 from pypi and ran into this problem. Since I am using django 1.7, instead of a deprecation, I am getting an error when I start the development server (simplejson has been removed from django.utils). How is the situation with django 1.7 support in general for this project?

@sterago and @devstorm21: If I am understanding your comments correctly, this closed issue shouldn't be a problem for you if your install of Python has the json library installed. The fix that @derekjamescurtis made corrects the problem with the deprecated Django version of JSON. Look at the file api.py in the source:

try:
    import json
except ImportError:
    from django.utils import simplejson as json

If your install of Python doesn't have the json lib installed, then the fallback is to try and import the Django version. Failing it, you SHOULD get an import error, because you don't have either (1) the Python JSON lib installed, nor (2) the Django version that does have simplejson installed, and the django-disqus library won't work, period.

A simple test would be to open Python on the command line and type import json. What is the result of that test?

@devstorm21 you are correct! I missed that one. Yes - that is a legitimate bug. I will quickly fork the repo, put in a fix and send a pull request.

Pull request sent: #62

Or you can use my fork for now until @derekjamescurtis merges it in: https://github.com/robnewman/django-disqus

BTW it looks like another person already fixed this issue and have their own fork due to the lack of merging by the owners: #43

You might like to try that fork instead - it looks like they caught another instance of simplejson in the template tags!

Hmmm. Looking through the issue list it seems that multiple developers have sent in pull requests solving this same issue over and over again, but some miss all the import fixes. It's pretty messy. For some reason none of them have been merged by @derekjamescurtis. Maybe because some of them don't fix all the instances? Only Derek can answer that.

FYI I just updated my fork to fix the template tags import of simplejson to just json. The fall back ImportError is to use simplejson as json. You should be set to use my fork, but it would be nice to see this fixed in the master branch...

Let me know if you have any problems with my fork.