Skip to content

Commit

Permalink
Merge pull request #206 from eaterek/django_json_serializer
Browse files Browse the repository at this point in the history
Use DjangoJSONEncoder - which handles additional django types including UUID
  • Loading branch information
crucialfelix authored Jun 23, 2017
2 parents 16b1105 + a1cf7b2 commit f31d866
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ajax_select/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django import forms
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.core.serializers.json import DjangoJSONEncoder
from django.db.models.query import QuerySet
from django.forms.utils import flatatt
from django.template.defaultfilters import force_escape
Expand Down Expand Up @@ -217,7 +218,9 @@ def render(self, name, value, attrs=None):
'html_id': self.html_id,
'current': value,
'current_ids': current_ids,
'current_reprs': mark_safe(json.dumps(initial)),
'current_reprs': mark_safe(
json.dumps(initial, cls=DjangoJSONEncoder)
),
'help_text': help_text,
'extra_attrs': mark_safe(flatatt(final_attrs)),
'func_slug': self.html_id.replace("-", ""),
Expand Down Expand Up @@ -441,8 +444,10 @@ def make_plugin_options(lookup, channel_name, widget_plugin_options, initial):
po['html'] = True

return {
'plugin_options': mark_safe(json.dumps(po)),
'data_plugin_options': force_escape(json.dumps(po))
'plugin_options': mark_safe(json.dumps(po, cls=DjangoJSONEncoder)),
'data_plugin_options': force_escape(
json.dumps(po, cls=DjangoJSONEncoder)
)
}


Expand Down

0 comments on commit f31d866

Please sign in to comment.