Django model with 2 foreign keys from the same table

I haven’t done this yet, but I used inspectdb to generate the models.py file from an existing DB that does exactly that – this is what inspectdb threw back, so it should work:

creator = models.ForeignKey(Users, null=True, related_name="creator")
assignee = models.ForeignKey(Users, null=True, related_name="assignee")

Hope that works for you – if it doesn’t I am going to have a problem too.

Leave a Comment