Skip to content

Commit

Permalink
Skip processing of the FormField if value is not required and empty 🌧
Browse files Browse the repository at this point in the history
  • Loading branch information
Sibyx committed Dec 19, 2019
1 parent a02e869 commit fcbee11
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.2 : 19.12.2019

- **Fix**: Skip processing of the `FormField` if value is not required and empty

## 0.5.1 : 19.12.2019

- **Fix**: Process `EnumField` even if it's not marked as required
Expand Down
2 changes: 1 addition & 1 deletion django_request_formatter/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.5.1'
__version__ = '0.5.2'
5 changes: 4 additions & 1 deletion django_request_formatter/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ def __init__(self, form: typing.Type, **kwargs):
def form(self):
return self._form

def to_python(self, value) -> dict:
def to_python(self, value) -> typing.Union[typing.Dict, None]:
if not value:
return None

form = self._form(value)
if form.is_valid():
return form.cleaned_data
Expand Down

0 comments on commit fcbee11

Please sign in to comment.