#4102: Allow UPDATE of only specific fields in model.save() --------------------------------------------------------+------------------- Reporter: Collin Grady <cgr...@the-magi.us> | Owner: cgrady Status: new | Milestone: Component: Database layer (models, ORM) | Version: SVN Resolution: | Keywords: Stage: Design decision needed | Has_patch: 1 Needs_docs: 1 | Needs_tests: 0 Needs_better_patch: 1 | --------------------------------------------------------+------------------- Changes (by clay):
* needs_better_patch: 0 => 1 Comment: Patch 4102.3 does not work correctly with multi-table inheritance -- child._modified_attrs is not visible by the parent, so a modified parent field is not updated. Something like this fixes it: Index: third-party/Django-1.0.2-final+4102.3+2705/django/db/models/base.py =================================================================== --- third-party/Django-1.0.2-final+4102.3+2705/django/db/models/base.py (revision 3362) +++ third-party/Django-1.0.2-final+4102.3+2705/django/db/models/base.py (working copy) @@ -358,7 +358,10 @@ non_pks = [f for f in meta.local_fields if not f.primary_key] modified_attrs = self._modified_attrs non_pks = [f for f in non_pks if (f.name in modified_attrs or f.attname in modified_attrs)] - self._reset_modified_attrs() + + # Reset modified attribute accumulator after parent fields have been updated + if cls == self.__class__: + self._reset_modified_attrs() # First, try an UPDATE. If that doesn't update anything, do an INSERT. pk_val = self._get_pk_val(meta) -- Ticket URL: <http://code.djangoproject.com/ticket/4102#comment:39> Django <http://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 -~----------~----~----~----~------~----~------~--~---