gregmuellegger/django-autofixture

`InstanceGenerator` does not support `Q` objects in `limit_choices_to`.

BertrandBordage opened this issue · 2 comments

autofixture.generators.InstanceGenerator fails when you defined your model with a Q object in limit_choices_to. InstanceGenerator assumes that limit_choices_to is always a dictionary.

It looks like InstanceSelector has the same issue.

Hi,
it seems that the InstanceSelector could be modified easily to also accept Q objects. But I'm not so convinced with the InstanceGenerator. This just supports a very small subset of the original limit_choices_to option that you would pass for example into a ManyToManyField. However the error message there could be improved.

What are your suggestions? Would you like to work on that and prepare a pull request for this?

Closing this due to inactivity. Comment here again if you still have questions about this.