Fix #18306 -- Defer and update_fields interaction. #213

wants to merge 2 commits into


None yet

3 participants

Django member

No description provided.

niwinz and others added some commits May 12, 2012
@niwinz niwinz Fixed #18306 -- Made deferred models issue update_fields on save
Deferred models now automatically update only the fields which are
loaded from the db (with .only() or .defer()). In addition, any field
set manually after the load is updated on save.
@akaariai akaariai Polished update_only and defer() interaction
The biggest changes are:
  - a bugfix to select_related handling
  - a bugfix for shared ._state.deferred_fields for instances loaded
    through the same queryset.
  - some code cleanup related to <> field.attname handling
  - documentation polish

The bugfixes were done by getting totally rid of ._state.deferred_fields
and instead relying on inspecting the instance's __dict__ and
__class__.__dict__ for deferred field information on save.

Refs #18306.
@alex alex commented on the diff Sep 7, 2012
@@ -386,6 +386,12 @@ perform an update on all fields.
Specifying ``update_fields`` will force an update.
+When saving a model fetched through deferred model loading
+(:meth:`~Model.only()` or :meth:`~Model.defer()`) only the fields loaded from
alex Sep 7, 2012 Django member

These links are wrong, the methods are on QuerySet, not Model.

Django member

Didn't see Alex' comment before, it is fixed now...

Closing this one as the patch has been applied some time ago...

@akaariai akaariai closed this Sep 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment