Opened 11 years ago

Closed 11 years ago

#4251 closed (duplicate)

ForeignKeys cannot be primary_key=True for syncdb

Reported by: David Cramer <dcramer@…> Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


syncdb throws an error why trying to sync a table with a ForeignKey set as primary_key=True

In most cases this would be invalid, but in cases such as the example it is correct

class Forum(models.Model):

id = models.IntegerField(primary_key=True)
game = models.ForeignKey(Game, related_name="dev_posts", primary_key=True)

Change History (1)

comment:1 Changed 11 years ago by Michael Axiak <axiak@…>

Resolution: duplicate
Status: newclosed

Multiple pk's are discussed in #373. Closed as a duplicate.

Note: See TracTickets for help on using tickets.
Back to Top