Zoltan Szalai
unread,Dec 2, 2014, 9:48:25 AM12/2/14Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django-res...@googlegroups.com
Hi,
First of all, huge thanks for 3.0! I've decided to migrate my latest
project to get a sense of it. One issue I ran into is with CountryField
from django-countries.
If the value is empty, 3.0 raises a "TypeError: Country(code=u'') is not
JSON serializable" exception. Checking out the 'to_representation'
method of ChoiceField makes it obvious why: Country(code=u'') is not in
('', None) and '' is not a key in the choices list and since 'Country' a
custom object it's not json serializable by default.
Putting something like:
if unicode(value) == '':
return ''
to the beginning of 'to_representation' would fix it but something
suggests it's not a great idea.
So what to do you think is the best way to solve this in 3.0 without
using custom serializer fields?
thanks
Zoltan