Opened 12 years ago

Closed 12 years ago

#18362 closed Bug (fixed)

model save with update_fields should accept both field.name and field.attname

Reported by: Anssi Kääriäinen Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: niwi@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently only field.name is accepted in update_fields argument. It seems field.attname should be accepted, too. Most commonly this will be encountered when trying to save a related field by "_id" appendix - for example update_fields=profile will work, but update_fieldsprofile_id will not work currently.

In my opinion this should work, as profile_id works in many other places, too, and this could be useful for automatic tracking of field changes for example.

Refs #4102, #18306.

Change History (3)

comment:1 by Anssi Kääriäinen, 12 years ago

Triage Stage: UnreviewedAccepted

hmmh - I can't edit the description. so, in above the examples are "update_fields=['profile']/['profile_id']" instead of the helpful wiki-links...

comment:2 by Andrei Antoukh, 12 years ago

Cc: niwi@… added
Has patch: set

comment:3 by Anssi Kääriäinen <akaariai@…>, 12 years ago

Resolution: fixed
Status: newclosed

In [0f49b2bce2d5b3c5891c8a329bab7dffe16fc79b]:

Fixed #18362 - Made model.save() update_fields accept attnames

Note: See TracTickets for help on using tickets.
Back to Top