Skip to content

Commit

Permalink
Made simplejson optional
Browse files Browse the repository at this point in the history
Now your lib can work with Django 1.7, where simplejson is deprecated.
Can you also make an update on PyPI?
  • Loading branch information
alekzvik committed Feb 6, 2015
1 parent 2a13d50 commit fc51733
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions nicedit/views.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
from django.utils import simplejson
try:
from django.utils import simplejson as json
except ImportError:
import json
from django.http import HttpResponse

from .forms import NicEditImageForm


def upload(request):
if not request.user.is_authenticated():
json = simplejson.dumps({
json_data = json.dumps({
'success': False,
'errors': {'__all__': 'Authentication required'}})
return HttpResponse(json, mimetype='application/json')
return HttpResponse(json_data, mimetype='application/json')
form = NicEditImageForm(request.POST or None, request.FILES or None)
if form.is_valid():
image = form.save()
json = simplejson.dumps({
json_data = json.dumps({
'success': True,
'upload': {
'links': {
Expand All @@ -24,6 +27,6 @@ def upload(request):
}
})
else:
json = simplejson.dumps({
json_data = json.dumps({
'success': False, 'errors': form.errors})
return HttpResponse(json, mimetype='application/json')
return HttpResponse(json_data, mimetype='application/json')

0 comments on commit fc51733

Please sign in to comment.