Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

`JSONFormField.clean` should return a python object and not it's string representation. #22

Closed
charettes opened this Issue Mar 29, 2013 · 4 comments

Comments

Projects
None yet
2 participants

Is there a reason why you don't return the json.loads?

e.g. forms.DateField.clean returns a date and forms.BooleanField.clean returns a bool.

Owner

derek-schaefer commented Apr 5, 2013

In my case, I only needed to validate the JSON and return it. However, I can see how returning a Python object would be useful. Perhaps a flag parameter on clean would be best.

This is definitely a misbehavior, does IntegerField.clean returns a an integer in it's string form '123' or as integer int.

Stating Django's form documentation:

In general, any cleaning method can raise ValidationError if there is a problem with the data
it is processing, passing the relevant error message to the ValidationError constructor. If no
ValidationError is raised, the method should return the cleaned (normalized) data as
a Python object.
Owner

derek-schaefer commented Jun 14, 2013

Indeed. This will be taken care of soonTM. Pull requests are always welcome.

Owner

derek-schaefer commented Jun 19, 2013

Change applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment