Code

Opened 7 years ago

Closed 7 years ago

#4251 closed (duplicate)

ForeignKeys cannot be primary_key=True for syncdb

Reported by: David Cramer <dcramer@…> Owned by: adrian
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: UI/UX:

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)

Attachments (0)

Change History (1)

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

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.