Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on ForeignKey to self and MPTTModel #15

Open
paulshannon opened this issue Jun 29, 2015 · 3 comments
Open

Error on ForeignKey to self and MPTTModel #15

paulshannon opened this issue Jun 29, 2015 · 3 comments

Comments

@paulshannon
Copy link
Contributor

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

@jgadelange
Copy link
Contributor

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 Brobin changed the title Error on MPTTModel Error on ForeignKey to self and MPTTModel Apr 1, 2016
@deepakmishra
Copy link

deepakmishra commented Jan 28, 2021

@Brobin is self referencing foreign key issue solved?

elif not field.null:

This line is checking .null, but still seeder is throwing the SeederException.

parent = models.ForeignKey("self", null=True, blank=True, related_name="children")

@AngelOnFira
Copy link
Collaborator

@deepakmishra I'm the primary maintainer for now, so you'd be best pinging me for faster responses 😃

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants