#4102: Allow UPDATE of only specific fields in model.save()
-------------------------------------+-------------------------------------
     Reporter:  Collin Grady         |                    Owner:  cgrady
  <cgrady@…>                         |                   Status:  new
         Type:  New feature          |                  Version:  SVN
    Component:  Database layer       |               Resolution:
  (models, ORM)                      |             Triage Stage:  Accepted
     Severity:  Normal               |      Needs documentation:  1
     Keywords:  update fields sql    |  Patch needs improvement:  1
  row table modified                 |                    UI/UX:  0
    Has patch:  1                    |
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by akaariai):

 Implementing only_fields kwarg for model .save() sounds like a plan. That
 would be really useful feature, simple to implement and I think nobody
 will give a -1 to that idea.

 In ticket #17332 is a patch which should allow (with minor changes)
 override of model._state. Also, the `ModelState` does have some methods in
 it which allow tracking of dirty field state (of course, implemented in a
 custom state class). That way 3rd party projects could pretty easily
 implement tracking of dirty field state in the way they wish (hashing,
 flags, storing the old values...). Using the ._state information you can
 then implement custom .save() which automatically saves only changed
 fields. Note that the important parts of the patch are the `ModelState`
 changes, and where .update()/clear() are called, rest is irrelevant to
 this ticket.

 It seems clear that a default behavior of saving only changed fields will
 not get into Django core.

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to