Opened 14 years ago
Closed 14 years ago
#15494 closed Bug (fixed)
Using only('pk') in related set raises FieldDoesNotExist
Description ¶
This is my first ticket, apologies if this is known or I've missed something in my report.
With model A and model B, where model B has a fk to A:
A().b_set.all().only('pk')
Raises "FieldDoesNotExist: B has no field named 'pk'"
In my example I'm instantiating a new object for brevity. The behaviour is the same with a saved object.
I've attached a simple patch, however I couldn't get the testrunner working, so I couldn't write a full patch. Also, I expect this isn't the best method, but I don't know enough about the ORM to know of a better fix.
Change History (8)
by , 14 years ago
Attachment: | only_pk_related.diff added |
---|
comment:1 by , 14 years ago
comment:2 by , 14 years ago
Needs tests: | set |
---|---|
Patch needs improvement: | set |
comment:3 by , 14 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
by , 14 years ago
Attachment: | only_pk.diff added |
---|
comment:5 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
Tests and better comments.