Opened 15 years ago
Closed 15 years ago
#11938 closed (duplicate)
`to_field` does not function as expected.
Reported by: | David Cramer | 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: | no | UI/UX: | no |
Description
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 SimpleModel.objects.get(user=self.user)
Attachments (2)
Change History (3)
by , 15 years ago
Attachment: | to_field_tests.py added |
---|
by , 15 years ago
Attachment: | to_field_tests.2.py added |
---|
comment:1 by , 15 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Additional test case on deletion.