Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Update admin.py, remove deprecated simplejson import #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions treeadmin/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
from django.contrib.admin.views import main
from django.db.models import Q
from django.http import HttpResponse, HttpResponseBadRequest, HttpResponseForbidden, HttpResponseNotFound, HttpResponseServerError
from django.utils import simplejson
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _, ugettext

from mptt.exceptions import InvalidMove

try:
import simpljson as json
except ImportError:
import json
import logging


Expand Down Expand Up @@ -318,7 +320,7 @@ def _toggle_boolean(self, request):
d.append(b)

# TODO: Shorter: [ y for x,y in zip(a,b) if x!=y ]
return HttpResponse(simplejson.dumps(d), mimetype="application/json")
return HttpResponse(json.dumps(d), mimetype="application/json")

def get_changelist(self, request, **kwargs):
return ChangeList
Expand Down Expand Up @@ -347,7 +349,7 @@ def changelist_view(self, request, extra_context=None, *args, **kwargs):
extra_context = extra_context or {}
extra_context['TREEADMIN_MEDIA_HOTLINKING'] = self.jquery_use_google_cdn
extra_context['TREEADMIN_JQUERY_NO_CONFLICT'] = self.jquery_no_conflict
extra_context['tree_structure'] = mark_safe(simplejson.dumps(
extra_context['tree_structure'] = mark_safe(json.dumps(
_build_tree_structure(self.model)))

return super(TreeAdmin, self).changelist_view(request, extra_context, *args, **kwargs)
Expand Down