JSONField breaks with model_to_dict
mjtorn opened this issue · comments
Hi!
I've been using a JSONField implementation I found floating around, but it's not as good as this project.
The one bug is, though, when I use django.forms.models.model_to_dict.
I'm confused about value_for_object here, because it returns the json representation,
while surely it could return the decoded json object?
My suggested fix would be to remove the method; the default superclass functionality seems good.
Or what do you think?
Or wait. Is that value_for_object and/or model_to_dict used in form validation? I might have misread the code;
the clean method tries also to call loads on the given value, so it might actually fail it if it's given a real data structure.
Wouldn't the first dumps then always be ok?
It might be best not to introduce the change, and I could make another pull request with only the contribute_to_class, although I would have to hack around at my code (a preferrable choice to either maintaining a fork or using something less established than your project)
Comments?
Yeah, let's close this, the form gets too fishy otherwise.