Added event create view

This commit is contained in:
fergal.moran
2012-08-27 16:15:22 +01:00
parent 3254b257f8
commit 54cf6972ba
1146 changed files with 7538 additions and 6168 deletions

17
core/serialisers/json.py Normal file
View File

@@ -0,0 +1,17 @@
from django.core.serializers import serialize
from django.utils.simplejson import dumps, loads, JSONEncoder
from django.db.models.query import QuerySet
from django.utils.functional import curry
class DjangoJSONEncoder(JSONEncoder):
def default(self, obj):
if isinstance(obj, QuerySet):
# `default` must return a python serializable
# structure, the easiest way is to load the JSON
# string produced by `serialize` and return it
return loads(serialize('json', obj, fields=('id', 'name')))
return JSONEncoder.default(self,obj)
# partial function, we can now use dumps(my_dict) instead
# of dumps(my_dict, cls=DjangoJSONEncoder)
dumps = curry(dumps, cls=DjangoJSONEncoder)