X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/c52436a7e25876ee3509df2467c2a9ef33303436..de73425f8a37835f8778fbcfd81c41493781f46a:/apps/wiki/helpers.py?ds=sidebyside diff --git a/apps/wiki/helpers.py b/apps/wiki/helpers.py index 553b1e44..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,13 +22,14 @@ 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) - super(JSONResponse, self).__init__( - json.dumps(data, cls=ExtendedEncoder), - mimetype="application/json", **kwargs) + data = json.dumps(data, cls=ExtendedEncoder) + super(JSONResponse, self).__init__(data, mimetype="application/json", **kwargs) # return errors