[Django] #18362: model save with update_fields should accept both field.name and field.attname

6 views
Skip to first unread message

Django

unread,
May 22, 2012, 7:37:35 PM5/22/12
to django-...@googlegroups.com
#18362: model save with update_fields should accept both field.name and
field.attname
----------------------------------------------+--------------------
Reporter: akaariai | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
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_fields['profile_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.

--
Ticket URL: <https://code.djangoproject.com/ticket/18362>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 22, 2012, 7:39:33 PM5/22/12
to django-...@googlegroups.com
#18362: model save with update_fields should accept both field.name and
field.attname
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by akaariai):

* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/18362#comment:1>

Django

unread,
May 30, 2012, 2:06:52 PM5/30/12
to django-...@googlegroups.com
#18362: model save with update_fields should accept both field.name and
field.attname
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) | Resolution:
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by niwi):

* cc: niwi@… (added)
* has_patch: 0 => 1


Comment:

Posible fix: https://github.com/niwibe/django/tree/ticket_18362

--
Ticket URL: <https://code.djangoproject.com/ticket/18362#comment:2>

Django

unread,
Jul 5, 2012, 9:39:30 AM7/5/12
to django-...@googlegroups.com
#18362: model save with update_fields should accept both field.name and
field.attname
-------------------------------------+-------------------------------------
Reporter: akaariai | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: master
(models, ORM) | Resolution: fixed
Severity: Normal | Triage Stage: Accepted
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Anssi Kääriäinen <akaariai@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [0f49b2bce2d5b3c5891c8a329bab7dffe16fc79b]:
{{{
#!CommitTicketReference repository=""
revision="0f49b2bce2d5b3c5891c8a329bab7dffe16fc79b"
Fixed #18362 - Made model.save() update_fields accept attnames
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18362#comment:3>

Reply all
Reply to author
Forward
0 new messages