Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#15121 closed (duplicate)

ForeignKey cascading deletes fail with Integrity Error when to_field attribute set to field other than primary key

Reported by: ben.kank@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.3-beta
Severity: Keywords: to_field, cascade, on_delete
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


ForeignKey cascading delete fails with Integrity Error when to_field argument set to field other than primary key. Setting the on_delete argument doesn't change this behavior either.

For example:

models.ForeignKey(Design, related_name='reports', to_field="uuid", on_delete=models.CASCADE)

Attachments (0)

Change History (2)

comment:1 Changed 3 years ago by carljm

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

This is actually a symptom of #11319. If fixing #11319 turns out to be too difficult to do before 1.3, the deletion code could potentially work around it so deletions don't fail - but that's a last resort. Marking as duplicate.

comment:2 Changed 3 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

Add Comment

Modify Ticket

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

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

Note: See TracTickets for help on using tickets.