gregmuellegger / django-autofixture

Can create auto-generated test data.
BSD 3-Clause "New" or "Revised" License
460 stars 118 forks source link

Self referencing model support #23

Closed jfyne closed 10 years ago

jfyne commented 10 years ago

To prevent max recursion depth errors when creating a model which references itself, I have slightly modified the behavior of generate_fk. When it detects that it is a self referencing foreign key field which allows None, instead of creating a new instance it just sets None. If the field does not allow None it throws a CreateInstanceError.

I think this is a sane default, your thoughts would be appreciated though.

Thanks!

gregmuellegger commented 10 years ago

Again: Excellent! You deliver good code. Thanks for your efforts! Just released 0.6.1 containing your changes: https://pypi.python.org/pypi/django-autofixture/0.6.1