Opened 18 years ago
Closed 18 years ago
#4251 closed (duplicate)
ForeignKeys cannot be primary_key=True for syncdb
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
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 |
Description
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)
Note:
See TracTickets
for help on using tickets.
Multiple pk's are discussed in #373. Closed as a duplicate.