Commit graph

49 commits

Author SHA1 Message Date
Sergey Tikhonov
6b88c888d3 fix model.save patched in FieldTracker (#353)
* fix model.save patched in FieldTracker

* add test for save call with args

* update changes
2018-12-10 21:35:26 +06:00
tumb1er
ba83be0b43 fix #330 patch MyModel.save instead of MyModel().save 2018-11-20 18:32:09 +03:00
Lucas Wiman
da65d0be32 Fix E30X too-few line spacing errors. 2018-07-02 12:20:38 -07:00
Lucas Wiman
7d6b45f0c1 Increase coverage: verify that accessing the descriptor from the class yields the descriptor object. 2018-06-28 17:04:57 -07:00
Lucas Wiman
ca2fbb4ccd Fix coverage for a codepath only executed in <1.10 environments. 2018-06-28 16:59:30 -07:00
Lucas Wiman
59347ef36f Correctly clean up recursion sentinel value. 2018-06-28 13:52:52 -07:00
Lucas Wiman
15f9393bb2 Handle API change in DeferredAttribute descriptor in django-trunk.
This should maintain compatibility with the next version of django.
2018-06-28 13:16:33 -07:00
Lucas Wiman
a84c3afddd Fix behavior of .previous() in Django 1.10+.
The complications are that when the attribute is set in Django 1.10,
it no longer counts as a deferred attribute, and it is not retrieved from the database.
Naively updating __set__ to retrieve the value if it is deferred leads to infinite
recursion because accessing the attribute involves loading data from the database
and trying to set the attribute based on that value. This commit introduces
a somewhat hacky flag that records whether we're already trying to set
the attribute further up in the call stack.
2018-06-28 13:15:56 -07:00
Lucas Wiman
5d410e9ccc Fix test failures from merge. 2018-06-28 11:29:44 -07:00
Lucas Wiman
98a1366608 Merge branch 'defer-has-changed' into django-1.11-compatibility 2018-06-21 12:52:33 -07:00
Lucas Wiman
90ed7fc905 Improve coverage. 2018-06-21 12:41:42 -07:00
Lucas Wiman
80b099f129 Do not override custom descriptors when present.
This commit adds a collection of wrapper classes for tracking fields
while still using custom descriptors that may be present. This fixes
a bug where deferring a model field with a custom descriptor meant
that the descriptor was overridden in all subsequent queries.
2018-06-21 12:41:42 -07:00
Lucas Wiman
be52bc9290 Add failing test for deferred attributes. 2018-06-21 12:41:42 -07:00
Lucas Wiman
0fc0b44c95 Remove version checks for django<1.8.
Support for older versions of django was dropped in 3.0.0.
2018-06-21 12:41:42 -07:00
Jack Cushman
d34043fd25 Avoid fetching deferred fields in has_changed 2018-02-10 10:53:36 -05:00
Alexey Evseev
9ee6065f81 Support Django 1.10 deferred FileField with FieldTracker 2016-09-08 18:00:48 +03:00
Jarek Glowacki
bbc076429a Nicer solution 2016-08-17 11:48:27 +10:00
Jarek Glowacki
922c49770e Django 1.10 support for FieldTracker 2016-08-15 12:24:07 +10:00
Roman
7ec978e1d8 1.10 fix 2016-05-27 20:32:16 +00:00
Mike Bryant
ff3f8e5546 Use all the fields to determine _id variants. Fixes #214
If a tracker is defined on an inherited model, where the parent has a ForeignKey,
the tracker will now correctly determine that the field_map takes `fk` -> `fk_id`
2016-03-31 15:45:19 +01:00
bboogaard
041ef6b838 Keep track of deferred fields on model instance
Instead of on FieldInstanceTracker instance

Signed-off-by: bboogaard <b.boogaard@auto-interactive.nl>
2014-08-19 10:29:03 +02:00
Carl Meyer
a127e32217 Revert "Use a signal handler instead of patching save."
This reverts commit 3496fe4291.
2014-07-31 18:08:24 -06:00
Matthew Schinckel
3496fe4291 Use a signal handler instead of patching save.
References #83.

Instead of patching the save method of a tracked model class, we can use
a signal handler on post_save, which means we can still pickle our model
class.

Note we can't just listen for the signal from the class we have, but
instead listen for all post_save signals. This means we actually install
a new signal handler for each tracked model class, which fires on all
model save occurrences (and returns immediately if this handler doesn't care).

We probably could improve this to have a registry of tracked models, or
something, that allows us to just install one signal handler, and filter
according to membership.
2014-05-12 14:32:59 +09:30
Michael van Tellingen
2bcddd5be9 Add fix for Django 1.4 2014-03-01 14:24:25 +01:00
Michael van Tellingen
6ffae1ad8f Add support for deferred fields in the FieldTracker 2014-03-01 13:34:17 +01:00
Trey Hunner
e1faec7577 Merge pull request #73 from silonov/json_fields_support
Json fields support
2013-08-17 01:46:31 -07:00
Trey Hunner
2679f6114b Merge branch 'silonov-json_fields_support'
Conflicts:
	CHANGES.rst
	model_utils/tests/tests.py
2013-08-17 01:40:09 -07:00
Mikhail Silonov
ef510d53dd Removed reinvented wheel 2013-08-12 13:22:34 +04:00
Trey Hunner
15910e04e7 Merge branch 'field-tracker-inheritance'
Conflicts:
	CHANGES.rst
2013-08-11 18:49:20 -07:00
silonov
f20e723952 Added more general mutable fields support instead of json-specific 2013-08-11 19:32:45 +04:00
silonov
630741b423 Added JSONEncoder().encode(...) check for json-like fields 2013-08-10 01:59:06 +04:00
Mikhail Silonov
8c6f343111 Added JSON Fields support 2013-08-08 18:02:12 +04:00
Mikhail Silonov
b9f954074c Fixed a bug causing KeyError when saving with the parameter update_fields in which there are untracked fields. 2013-08-08 13:22:25 +04:00
Trey Hunner
98f078d718 Allow FieldTracker to work in child models
Fixes #57.
2013-07-29 12:54:49 -07:00
Trey Hunner
1474a48084 Improve FieldTracker docstrings 2013-05-28 10:14:49 -07:00
Trey Hunner
9dc3dacabf Fix FieldTracker's has_changed (fixes gh-51)
The FieldTracker has_changed method no longer returns True for any input
when the instance is unsaved and no longer raises a FieldError for
fields after the first save.  The original ModelTracker behavior is
maintained.
2013-05-24 22:22:20 -07:00
Trey Hunner
d28f3860cf Change FieldTracker `current` for unsaved model
Return None values instead of an empty dict
2013-05-23 16:38:12 -07:00
Trey Hunner
d190239c1f Improve docstrings and variables for FieldTracker 2013-05-23 16:25:10 -07:00
Trey Hunner
54c996f17f Don't compare FK instances in FieldTracker 2013-05-23 13:18:21 -07:00
Trey Hunner
6532784acd Create FieldTracker that mirrors ModelTracker 2013-05-23 12:50:34 -07:00
Trey Hunner
4f2673e6a4 Fix str/unicode problems in Python 3
Changes:
- Use unicode_literals from the future for Python 2.6.5+
- Use six's text_type for proper unicode use in Python 2/3
2013-04-12 14:16:42 -07:00
Trey Hunner
81c7e40e60 Fix iterator/list problems for Python 3 support 2013-04-12 14:16:42 -07:00
Trey Hunner
cddcbd4e42 ModelTracker: pass kwargs to parent save correctly
Fixes usage of update_fields in save()
2013-03-27 16:59:42 -07:00
Trey Hunner
d24dbc6c38 Fix ModelTracker for obj.save(update_fields=[...]) 2013-03-27 16:59:42 -07:00
Trey Hunner
45ac3bd03f Fix return value of ModelTracker.current pre-save 2013-02-18 17:32:30 -08:00
Trey Hunner
1ae2effc22 Merge ModelTracker and descriptor classes 2013-02-18 16:36:05 -08:00
Trey Hunner
a68649c9e7 Rename current_fields to current 2013-02-18 16:26:54 -08:00
Trey Hunner
f4512642cb Remove unnecessary use of setattr 2013-02-18 16:22:11 -08:00
Trey Hunner
676424e388 Move ModelTracker to tracker module 2013-02-18 16:21:14 -08:00