Skip to content

Commit

Permalink
Convert empty string to None if field allows nulls
Browse files Browse the repository at this point in the history
  • Loading branch information
cachitas committed Apr 16, 2019
1 parent 09fbb26 commit a08104c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pyforms_web/widgets/django/modelform.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,9 @@ def update_object_fields(self, obj):
if isinstance(field, models.CharField) and value is None and field.null is False:
value = ''

if value == '' and field.null:
value = None

setattr(obj, field.name, value)

return obj
Expand Down

0 comments on commit a08104c

Please sign in to comment.