django-seed
django-seed copied to clipboard
Error on ForeignKey to self and MPTTModel
Cannot handle MPTTModel; I think it's choking on any ForiegnKey to self. WIll confirm
This is not only an issue when using MPTTModels. (so maybe rename the issue?)
It also happens when adding a ForeignKey('self') to a model.
Also, I believe the error handling in ModelSeeder.build_relation() is correct. When the related_model is not generated by the seeder, but the field can be null it should not throw an error. Maybe the seeder should also sometimes return None?
@Brobin is self referencing foreign key issue solved?
https://github.com/Brobin/django-seed/blob/6643565b52cd96f78d17709293b533b1464c089a/django_seed/seeder.py#L24
This line is checking .null, but still seeder is throwing the SeederException.
parent = models.ForeignKey("self", null=True, blank=True, related_name="children")
@deepakmishra I'm the primary maintainer for now, so you'd be best pinging me for faster responses :smiley:
If you are testing how django-seed works, make sure to be building from master since I've added quite a bit that hasn't been released yet. I fear I added some regressions, so I'm working on a testing suite that should have enough breadth to be quite resilient. I also think there are some issues while generating models with foreign keys/many-to-many, but I haven't looked at it in a while.