You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This means that even modifying a field to add Model.objects.none() to the empty values doesn't work to ignore the empty queryset, so the cleaned value is always saved.
This can cause issues when the model being imported is referenced by an optional OneToOne relationship from another model and this model has an optional m2m, in this case the m2m is saved even when it shouldn't and it raises an error.
To Reproduce
...
Versions (please complete the following information):
Django Import Export: 3.30
Python 3.8.10
Django 4.2
Expected behavior
I think we could return an empty list instead of an empty queryset in this case, that way we can add '[]' to empty_values in Field to solve it. Alternatively we could just return an empty string and modify the rest of the code to ignore falsy or empty values.
Screenshots
The text was updated successfully, but these errors were encountered:
Thanks for raising. I would suggest to look at release 4. We will be changing the interface in a few places to standardize it, so would be a good opportunity to put a fix in. I think that returning an empty list would work ok, so no need to modify Field.
If you felt like creating a PR, that would be appreciated. Contributing guidelines are here.
Describe the bug
Try this in the python shell:
This means that even modifying a field to add
Model.objects.none()
to the empty values doesn't work to ignore the empty queryset, so the cleaned value is always saved.This can cause issues when the model being imported is referenced by an optional OneToOne relationship from another model and this model has an optional m2m, in this case the m2m is saved even when it shouldn't and it raises an error.
To Reproduce
...
Versions (please complete the following information):
Expected behavior
I think we could return an empty list instead of an empty queryset in this case, that way we can add '[]' to
empty_values
inField
to solve it. Alternatively we could just return an empty string and modify the rest of the code to ignore falsy or empty values.Screenshots
The text was updated successfully, but these errors were encountered: