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
When trying to bake a model with mandatory generic relation and set _fill_optional=True at the same time, I get AttributeError due to invalid reference to generic FK field's null attribute.
If I add GenericForeignKey to the tuple ref. below (followed by its import, of course), the problem disappears.
We also have this problem, and are currently pinned to version <1.3 because of it. Would a patch containing the above change be acceptable? What else would be needed?
@paduszyk@paulredman- I got a bit of time to dig into this issue. GenericForeignKey is not included in _skip_field() logic, as it is (and I believe, should be) allowed to be overwritten.
For example, there is a test TestFillingGenericForeignKeyField.test_iteratively_filling_generic_foreign_key_field that will fail in case we do that.
After playing around a bit, I have some kind of a workaround to cover the case described here: #438
(please, check out the test and correct me if I got it wrong).
While this solution works, I do not think it is the right way of solving this and would need to dig more.
When trying to bake a model with mandatory generic relation and set
_fill_optional=True
at the same time, I getAttributeError
due to invalid reference to generic FK field'snull
attribute.If I add
GenericForeignKey
to the tuple ref. below (followed by its import, of course), the problem disappears.model_bakery/model_bakery/baker.py
Line 571 in 75735ff
I guess the problem is that generic FK is identified as nullable, thus optional... Anyone can explain why this has not been done yet?
The text was updated successfully, but these errors were encountered: