django-ajax-forms
django-ajax-forms copied to clipboard
date json serializable error
Hi,
When you use Modelform and you have (auto_now_add=True) you have this error: TypeError: datetime.datetime(2013, 12, 4, 17, 23, 51, 893632, tzinfo=<UTC>) is not JSON serializable
For correct this:
add :
from django.core.serializers.json import DjangoJSONEncoder
import json
and change in views.py:
def convert_context_to_json(self, context):
return json.dumps(context, cls=DjangoJSONEncoder)
also like that deprecated use of simplejson is corrected.
(source from http://stackoverflow.com/a/5781657)