Opened 5 years ago

Closed 4 years ago

#11938 closed (duplicate)

`to_field` does not function as expected.

Reported by: dcramer Owned by: nobody
Component: Database layer (models, ORM) Version: 1.1
Severity: Keywords: to_field
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


In lookups involving a ForeignKey, or a ManyToMany intermediary table using a to_field they fail due to looking for the primary key, rather than the field specified by to_field.

For example:

    user = models.ForeignKey(User, to_field="username")
    # Fails

Attachments (2) (1.0 KB) - added by dcramer 5 years ago. (1.4 KB) - added by dcramer 5 years ago.
Additional test case on deletion.

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by dcramer

Changed 5 years ago by dcramer

Additional test case on deletion.

comment:1 Changed 4 years ago by russellm

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

This is a dupe of #11319, which is itself an amalgam of #10243 and #10785.

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.