X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/32974185d5e2b1bdc197b4f5dcab259b5de3c6b4..391b3e40affcdacc99dae60cc2dd51f30114fd94:/apps/wiki/helpers.py diff --git a/apps/wiki/helpers.py b/apps/wiki/helpers.py index 9b326d54..8983e401 100644 --- a/apps/wiki/helpers.py +++ b/apps/wiki/helpers.py @@ -1,9 +1,11 @@ -from django import http -from django.utils import simplejson as json -from django.utils.functional import Promise +# -*- coding: utf-8 -*- from datetime import datetime from functools import wraps +from django import http +import json +from django.utils.functional import Promise + class ExtendedEncoder(json.JSONEncoder): @@ -20,12 +22,13 @@ class ExtendedEncoder(json.JSONEncoder): # shortcut for JSON reponses class JSONResponse(http.HttpResponse): - def __init__(self, data={}, **kwargs): + def __init__(self, data=None, **kwargs): + if data is None: + data = {} # get rid of mimetype kwargs.pop('mimetype', None) data = json.dumps(data, cls=ExtendedEncoder) - print data super(JSONResponse, self).__init__(data, mimetype="application/json", **kwargs)