Skip to content

Commit

Permalink
Ignore ModelMultipleChoiceField in Form::fill method 🐋
Browse files Browse the repository at this point in the history
  • Loading branch information
Sibyx committed Oct 29, 2020
1 parent 2552a33 commit db63fa3
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 106 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.16.1 : 29.10.2020

- **Fix**: Ignore `ModelMultipleChoiceField` in `Form::fill()`

## 0.16.0 : 14.09.2020

- **Change**: Correctly resolve key postfix if `ModelChoiceField` is used in `Form::fill()`
Expand Down
6 changes: 5 additions & 1 deletion django_api_forms/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Union, List

from django.core.exceptions import NON_FIELD_ERRORS, ValidationError
from django.forms import ModelChoiceField
from django.forms import ModelChoiceField, ModelMultipleChoiceField
from django.forms.forms import DeclarativeFieldsMetaclass
from django.utils.translation import gettext as _

Expand Down Expand Up @@ -190,6 +190,10 @@ def fill(self, obj, exclude: List[str] = None):
if hasattr(field, 'ignore_fill') and field.ignore_fill:
continue

# ModelMultipleChoiceField is not fillable too (yet)
if isinstance(field, ModelMultipleChoiceField):
continue

"""
We need to changes key postfix if there is ModelChoiceField (because of _id etc.)
We always try to assign whole object instance, for example:
Expand Down
2 changes: 1 addition & 1 deletion django_api_forms/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.16.0'
__version__ = '0.16.1'
Loading

0 comments on commit db63fa3

Please sign in to comment.