Skip to content

Loading…

Check if the value is a string before attempting to deserialize #14

Merged
merged 1 commit into from

2 participants

@bruth

No description provided.

@bradjasper bradjasper merged commit 2f42736 into bradjasper:master
@bradjasper
Owner

Good fix, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 5 additions and 4 deletions.
  1. +5 −4 jsonfield/fields.py
View
9 jsonfield/fields.py
@@ -14,10 +14,11 @@ def clean(self, value):
value = super(JSONFormField, self).clean(value)
- try:
- json.loads(value)
- except ValueError:
- raise FormValidationError(_("Enter valid JSON"))
+ if isinstance(value, basestring):
+ try:
+ json.loads(value)
+ except ValueError:
+ raise FormValidationError(_("Enter valid JSON"))
return value
class JSONField(models.TextField):
Something went wrong with that request. Please try again.