model-bakers/model_bakery

`GenericForeignKey` not accounted for in `baker._skip_field()`

paduszyk opened this issue · 4 comments

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.

if isinstance(field, (AutoField, GenericRelation, OrderWrt)):

I guess the problem is that generic FK is identified as nullable, thus optional... Anyone can explain why this has not been done yet?