django-seed icon indicating copy to clipboard operation
django-seed copied to clipboard

Error on ForeignKey to self and MPTTModel

Open paulshannon opened this issue 10 years ago • 3 comments
trafficstars

Cannot handle MPTTModel; I think it's choking on any ForiegnKey to self. WIll confirm

paulshannon avatar Jun 29 '15 19:06 paulshannon

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?

jgadelange avatar Mar 31 '16 20:03 jgadelange

@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 avatar Jan 28 '21 09:01 deepakmishra

@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.

AngelOnFira avatar Jan 28 '21 13:01 AngelOnFira