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
João Amaro
6d2ba63387
update changelog and versions for 3.1.2
2018-05-09 14:45:37 -03:00
Václav Dohnal
a6ce9fcc3b
add N/A as Language-Team
2018-05-04 13:51:46 +02:00
Václav Dohnal
db35475ece
add link to the issue tracker on Github
2018-05-04 13:51:15 +02:00
Václav Dohnal
d7e8144d4c
add missing file header
2018-05-04 13:50:58 +02:00
Václav Dohnal
248db7bde4
update czech (cs) translations
2018-05-04 13:46:16 +02:00
Václav Dohnal
b15f44c260
add czech (cs) translations
2018-05-04 13:45:53 +02:00
Hanley Hansen
18dfb6b2cf
Merge pull request #279 from hanleyhansen/inheritance-iterable
...
Update InheritanceIterable to inherit from ModelIterable instead of BaseIterable
2018-05-02 14:14:22 -04:00
Jack Cushman
d34043fd25
Avoid fetching deferred fields in has_changed
2018-02-10 10:53:36 -05:00
Tony Narlock
baa8bae1c0
update changelog and versions for 3.1.1
2017-12-17 07:45:56 -06:00
Tony Narlock
8a0d00b939
tag 3.1.0
2017-12-11 08:27:41 -06:00
Tony Narlock
c4d72123ef
rm use_for_related_fields #290
2017-12-07 12:20:50 -06:00
Tony Narlock
a07140e771
Use _chain for django 2.0, #295
2017-12-07 11:13:39 -06:00
Hanley
0a809df4da
make InheritanceIterable inherit from ModelIterable instead of BaseIterable
2017-06-23 09:51:32 -04:00
Arseny Sysolyatin
69d6c6040a
Russian locale added
2017-05-22 20:23:24 +03:00
Carl Meyer
100d2d7a24
Bump version to 3.0.1a1.
2017-04-13 16:51:52 -07:00
Carl Meyer
2e3b50dcb6
Bump version to 3.0.0.
2017-04-13 16:49:58 -07:00
Sachi King
8cb21aabbc
Support django 1.11 iterator changes
...
Django starting with 1.9 switched to using a class to provide an
iterator for the querymanager. Between 1.9 and 1.10 changes slowly
stopped referencing that function and instead started calling
_iterator_class directly.
As the functionality model-utils is patching has moved, this patch moves
the iterator logic to a class to match the changes that have been made
in Django in version 1.9.
As Django 1.8 is a LTS release that is still supported, iterator()
is retained in the InheritanceQuerySetMixin and can be removed when
support for Django 1.8 is removed. This goes for the try-except in the
import statements as well.
2017-04-02 21:53:15 +10:00
Bruno Alla
10ebc16271
Exclude tests from distribution
...
fixes #258
2017-02-15 23:00:10 +00:00
Romain G
d07b992b94
Drop old get_query_set syntax, replaced by get_queryset now
2017-01-12 18:34:47 +00:00
Ryan P Kilby
e148c670d1
Fix django 2.0 warnings
2017-01-12 12:16:46 -05:00
Ryan P Kilby
fda2d39ec4
Drop unsupported django versions
2017-01-12 12:16:40 -05:00
Carl Meyer
625e1041cc
Bump version to 2.6.2.a1.
2017-01-11 16:07:17 -08:00
Carl Meyer
269f6f130f
Bump version to 2.6.1.
2017-01-11 15:37:06 -08:00
Romain G
63e5c59c66
Simplify test models + make it compatible for old Django versions
2017-01-09 19:16:09 +00:00
Romain G
679af01f26
Add fix + tests for abstract manager inheritance issue with StatusModel
2017-01-09 19:02:59 +00:00
Bruno Alla
2af54972eb
Revert unrelated change regarding related fields
...
Remove attribute use_for_related_fields in SoftDeletableManagerMixin.
2017-01-05 18:32:13 +00:00
Bruno Alla
063332643d
Split SoftDeletableQuerySet/Manager into Mixin
2017-01-05 14:40:03 +00:00
Bruno Alla
0efaad1218
Fix issue when extend QuerySet and Manager - fixes #249
2017-01-05 14:29:35 +00:00
Bruno Alla
4311e24e98
Add soft parameter to delete method instead of new one
2016-11-28 23:45:48 +00:00
Bruno Alla
6efab67b79
Merge remote-tracking branch 'carljm/master' into feature/soft-delete-purge
...
# Conflicts:
# model_utils/tests/tests.py
2016-11-28 23:31:16 +00:00
romgar
eb41dc0ea0
Prevent test manual import for Django 1.6+. No impact on Django 1.7/1.8, duplicating all test runs in Django 1.6
2016-11-24 21:31:55 +00:00
romgar
2a9c199819
Remove test duplication related to TestCase inheritance in different files
2016-11-24 21:31:23 +00:00
romgar
6fefc53c58
Separate tests in small files, making it easier to edit/add new ones/not conflict on different merge requests
2016-11-23 23:49:53 +00:00
Carl Meyer
94870b2510
Merge pull request #242 from romgar/ticket_241_double_monitor_field_recursion_error
...
Tests to demonstrate recursion error with double MonitorField and defer()/only() usage
2016-11-21 11:13:31 -08:00
romgar
8ecf75144b
Update tests to use freezegun to avoid time resolution issues on Windows
2016-11-20 22:08:07 +00:00
romgar
e2440a6872
Add tests to prevent regression in MonitorField behaviour if we filter out deferred fields in _save_initial
2016-11-19 12:08:48 +00:00
romgar
93dd940a5d
Remove defered fields in _save_initial only for Django 1.10+
2016-11-18 23:31:45 +00:00
romgar
2455c983fc
Restore initial indentation
2016-11-18 23:12:39 +00:00
romgar
72158f1820
Avoid to directly initialise a monitored field if defered to avoid recursion issue
2016-11-18 23:11:23 +00:00
romgar
e9d57e60fe
Add test to demonstrate issue #241
2016-11-18 00:24:57 +00:00
Bruno Alla
ff4afd7288
Add a purge_from_db to SoftDeletableModel
2016-11-17 08:56:59 +00:00
Bruno Alla
516c457747
SoftDeletableModel: use correct DB connection
...
When deleting a SoftDeletableModel instance, the `using` parameter
should be passed down to the `save()` method.
https://docs.djangoproject.com/en/1.10/topics/db/multi-db/#selecting-a-d
atabase-for-save
2016-11-09 19:49:31 +00:00
Carl Meyer
e1a3cee4d3
Bump version to 2.6.1.a1.
2016-09-19 08:05:40 -06:00
Carl Meyer
a9a8451fc9
Bump version to 2.6.
2016-09-19 08:03:42 -06:00
Radosław Ganczarek
9e90dde2e8
Add SoftDeletableModel
2016-09-12 15:11:34 +02: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
Carl Meyer
65b0823e16
Bump version to 2.5.3a1.
2016-08-09 15:09:11 -06:00
Carl Meyer
da8e8cf3c9
Include runtests.py in sdist; bump version to 2.5.2.
2016-08-09 15:06:49 -06:00
Carl Meyer
34e4b6880f
Bump version to 2.5.2a1.
2016-08-03 08:44:29 -06:00
Carl Meyer
5904008eab
Bump version and update changelog for 2.5.1 release.
2016-08-03 08:38:59 -06:00
Roman
7ec978e1d8
1.10 fix
2016-05-27 20:32:16 +00:00
Artis Avotins
d1337d5a7c
Fixed a bug with Django >= 1.9 where values_list was called on
...
InheritanceQuerySet with `select_subclasses` applied as strings
raised AttributeError exception.
Adds a new test case `test_dj19_values_list_on_select_subclasses`
2016-05-25 18:58:03 +02:00
Carl Meyer
c5417eb613
Bump version for dev.
2016-04-18 15:08:15 -06:00
Carl Meyer
a43027ccee
Bump version to 2.5.
2016-04-18 15:02:40 -06: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
Adam Bogdał
4f39ce9497
Add support for Django 1.10
2016-02-09 00:22:12 +01:00
Carl Meyer
f1f8749fa9
Bump version to 2.4.1a1.
2015-12-02 10:55:59 -07:00
Carl Meyer
3c8fe6a7d2
Bump version to 2.4.
2015-12-02 10:43:11 -07:00
Karl WnW
ce8deed5ca
Fix _clone signature for Django<1.9
...
InheritanceQuerySetMixin._clone signature conflicts with django
ValuesQuerySet._clone code which calls super like this:
"c = super(ValuesQuerySet, self)._clone(klass, **kwargs)"
2015-11-02 17:52:43 +01:00
jarekwg
81eba92e61
flakes
2015-10-29 09:37:21 +11:00
jarekwg
1d473ec6a9
Test InheritanceManager fail against a different model
2015-10-29 09:33:45 +11:00
jarekwg
01514db83c
Update MutableField for 1.9
2015-10-29 08:12:35 +11:00
jarekwg
201aa3bf30
Half-assed use of User model raises exceptions in 1.9b1
2015-10-29 08:12:02 +11:00
jarekwg
bbad2b7b47
Hide _clone params in kwargs to match django 1.9 signature
2015-10-29 02:00:49 +11:00
jarekwg
2824ec2e48
Remove PassThroughManager
...
As of Django 1.7, QuerySet.as_manager() achieves the same result.
2015-10-29 00:10:28 +11:00
jarekwg
7a33e14f4b
Get StatusFields working
2015-10-29 00:02:46 +11:00
jarekwg
665fc04b7e
Must use the 'Now' database function in django>=1.9
2015-10-28 23:47:33 +11:00
Carl Meyer
165e0ec495
Bump version for 2.4 development.
2015-07-20 10:32:18 -06:00
Carl Meyer
443108c7ad
Set version for 2.3.1 release.
2015-07-20 10:22:27 -06:00
Carl Meyer
114f4fe228
Add script and makefile tasks for making and compiling messages; un-gitignore .mo files.
2015-07-20 10:20:11 -06:00
Carl Meyer
ab4a2b4ce4
Bump version to 2.4a1.
2015-07-17 13:02:07 -06:00
Carl Meyer
b1c183d475
Bump version to 2.3.
2015-07-17 11:38:39 -06:00
Philipp Steinhardt
1bfee88c06
* clean up po file header
2015-07-02 13:53:39 +02:00
Philipp Steinhardt
5218b483c5
* add german translations
2015-07-01 14:16:40 +02:00
Sergey Zherevchuk
608028aba8
Fix #169 issue
...
Hardcoding no_excerpt_field field in deconstruct() method of SplitField class
2015-06-18 11:11:28 +03:00
Carl Meyer
d797996d13
Fix Python 2.6 compatibility.
2015-01-28 12:17:34 -07:00
Carl Meyer
a1088dba52
Simpler cross-version implementation of _field_exists.
2015-01-28 10:59:20 -07:00
Carl Meyer
3f9b1cfac8
Fix select_subclasses for Django 1.8.
2015-01-27 16:48:06 -07:00
Carl Meyer
3110794afc
Fix 'add_*_manager' signal handlers for Django 1.8+.
2015-01-27 16:43:29 -07:00
ad-m
50caabdd2e
Fix #156 issue
2014-10-29 00:27:10 +01:00
Carl Meyer
9786672361
Remove dead code branch.
2014-09-22 12:49:35 -06: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
54d915bd4a
Bump version to 2.3a1.
2014-07-31 18:57:29 -06:00
Carl Meyer
c62fe9446d
Add Changelog entry for revert of GH-130; bump version to 2.2.
2014-07-31 18:16:15 -06: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
Carl Meyer
a0ba93f8c2
Bump version to 2.2a1.
2014-07-25 10:00:46 -06:00
Carl Meyer
24fa8945bb
Bump version to 2.1.0.
2014-07-25 09:52:55 -06:00
Keryn Knight
e353a01a9a
Implemented ability to change modified fields manually.
2014-07-01 14:38:58 +01:00
Keryn Knight
500dd470cd
Tests demonstrating how lying about a modified field ought to be possible.
2014-07-01 14:36:22 +01:00
Matthew Schinckel
8fa34bc609
Add test that may not do anything.
...
I'm not sure this test is actually useful: it's designed to show the
interaction of select_subclasses and instance_of, but I don't think
it adds much value.
2014-05-22 21:41:16 +09:30
Matthew Schinckel
02e19e45b4
Okay, now we are getting somewhere.
...
By itself, .instance_of(*models) will actually call select_subclasses(*models),
which results in just those objects being cast to subclasses.
However, if you want the casting to grandchildren (which is supported only in
django 1.6+), then you may use an extra call to .select_subclasses() (without
arguments, to select all subclasses).
It doesn't deal with @kezabelle's discussion of mixed-use of select_subclasses/
instance_of, I still need to look at that.
But it does pass all current tests...
2014-05-22 21:31:31 +09:30
Matthew Schinckel
f54c9a7c95
Remove dead code, add comments.
2014-05-22 21:02:19 +09:30
Matthew Schinckel
4128524eb4
WIP: this fails on django < 1.6
...
I think this is actually related to the issue related in #23 .
2014-05-20 20:58:25 +09:30
Matthew Schinckel
f06b573772
Add tests to show we actually do correctly filter the objects.
2014-05-16 22:49:20 +09:30
Matthew Schinckel
5e8ebef5b1
Add ability to filter an InheritanceQuerySet by model.
...
This is based upon the feature in django-polymorphic, where you
can do:
SuperClass.objects.instance_of(SubClass)
This will result in only objects of the subclass being fetched.
Note: this works with any queryset, keeping the filtering and
ordering applied there.
2014-05-16 20:23:04 +09:30
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
Rodney Folz
2905d1a307
Fix bug where you could only run makemigrations once without error.
2014-04-25 14:17:42 -07:00
Rodney Folz
85a9f8e6b1
Fix "model '%s' must have a %s choices class attribute" error on migrations.
2014-04-25 13:32:49 -07:00
Rodney Folz
db5e1f99fc
Fix "MonitorField requires a "monitor" argument"
2014-04-23 19:55:39 -07:00
Rodney Folz
f02b0912b2
Failing test for Django 1.7 makemigrations
...
======================================================================
ERROR: test_migrate (model_utils.tests.tests.MigrationsTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/user/projects/django-model-utils/model_utils/tests/tests.py", line 42, in test_migrate
call_command('migrate', fake=True)
File "/home/user/projects/django-model-utils/.tox/py27-trunk/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 167, in call_command
return klass.execute(*args, **defaults)
File "/home/user/projects/django-model-utils/.tox/py27-trunk/local/lib/python2.7/site-packages/django/core/management/base.py", line 337, in execute
output = self.handle(*args, **options)
File "/home/user/projects/django-model-utils/.tox/py27-trunk/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 138, in handle
ProjectState.from_apps(apps),
File "/home/user/projects/django-model-utils/.tox/py27-trunk/local/lib/python2.7/site-packages/django/db/migrations/state.py", line 71, in from_apps
model_state = ModelState.from_model(model)
File "/home/user/projects/django-model-utils/.tox/py27-trunk/local/lib/python2.7/site-packages/django/db/migrations/state.py", line 136, in from_model
e,
TypeError: Couldn't reconstruct field name_changed on tests.Monitored: MonitorField requires a "monitor" argument
2014-04-23 19:10:04 -07:00
Keryn Knight
8a1d0662f1
Provide dir() support for PassThroughManagers.
...
Reported in #55 by erikcw.
2014-04-15 08:48:01 +01:00
Carl Meyer
61923571b9
Bump version to 2.0.3.post1 for dev.
2014-03-19 22:48:13 -06:00
Carl Meyer
36b7e600c6
Bump version to 2.0.3 for release.
2014-03-19 22:43:48 -06:00
Matthew Schinckel
93500bb381
Ensure we call get_query_set on django 1.5-
...
Supersedes https://github.com/carljm/django-model-utils/pull/106
I can't actually see why this works, but it does: tests pass
after this that failed before.
2014-03-20 13:11:00 +10:30
Matthew Schinckel
a49936c267
Test case demonstrating relation failure.
...
https://github.com/carljm/django-model-utils/issues/120
2014-03-20 11:12:38 +10:30
Seán Hayes
3f7378ef60
Allow PassThroughManager subclasses to accept additional params.
2014-03-07 06:32:34 -05:00
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
Michael van Tellingen
1bab9c492d
Add failing test
2014-03-01 12:20:13 +01:00
Carl Meyer
f26b33acbc
Merge pull request #114 from rsenkbeil/inheritance-manager-self-reference
...
Fix InheritanceManager when the model has a self reference.
2014-02-19 15:41:01 -07:00
Ryan Senkbeil
617ec2af01
Fix InheritanceManager when the model has a self reference.
...
Otherwise, we reach max recursion depth.
2014-02-19 15:28:01 -06:00
Carl Meyer
fe0eceaa74
Bump version to 2.0.2.post1.
2014-02-19 14:01:51 -07:00
Carl Meyer
923f131084
Bump version to 2.0.2.
2014-02-19 13:59:49 -07:00
Carl Meyer
6579f5d61f
Bump version to 2.0.1.post1.
2014-02-11 15:03:08 -07:00
Carl Meyer
d77608ef76
Bump version to 2.0.1.
2014-02-11 14:58:18 -07:00
Carl Meyer
f19755ae81
Merge pull request #105 from patrys/patch-1
...
Don't try to access __slots__ during copy()
2014-01-25 16:35:09 -08:00
Carl Meyer
febc3d645a
Merge pull request #101 from funkybob/issue-34
...
Attempt to carry over extras(select) values from parent
2014-01-25 16:25:36 -08:00
Carl Meyer
26f4d7c8f5
Silence BooleanField default warnings.
2014-01-25 17:11:26 -07:00
funkybob
a5fe3de330
Deal with Django <1.7 using SortedDict wherein keys() is a generator, not a view
2014-01-21 09:19:54 +11:00
Patryk Zawadzki
80547335c0
Don't try to access __slots__ during copy()
...
When subclassing Django will copy managers from the ancestor class. Copying in turn calls `copy.copy()` which checks whether the object uses `__slots__` or `__dict__`. This could result in the manager calling `self.get_queryset()` before all models get registered with the ORM.
2014-01-20 12:50:37 +01:00
funkybob
91b07079e0
Use legacy compatible approach
2014-01-14 15:05:03 +11:00
funkybob
cb362f4a12
Shorten test docstring
2014-01-13 16:49:18 +11:00
Carl Meyer
6512e3e00e
Remove trailing whitespace.
2014-01-10 16:29:59 -07:00
Douglas Meehan
33c600e28c
edited class names
2014-01-10 16:18:10 -05:00
Douglas Meehan
9e024a14af
removed trailing whitespace
2014-01-10 16:15:42 -05:00
Douglas Meehan
aaf1fc8636
changed class names to be more descriptive
2014-01-10 16:06:08 -05:00
Douglas Meehan
55a15f7e55
Update managers.py
2014-01-09 16:58:51 -05:00
Douglas Meehan
72c8f0bc18
moved get_query_set = get_queryset from the mixin to the manager
2014-01-09 21:47:46 +00:00
Curtis Maloney
0e77c327f5
Update tests.py
2014-01-09 15:46:11 +11:00
Douglas Meehan
c787a98f21
removed GeoDjango specific code. Abstracted all managers
2014-01-08 17:19:00 +00:00
Douglas Meehan
e7c3f6b28e
edited doc string
2014-01-08 16:57:59 +00:00
Douglas Meehan
a1ffac9fa7
edited class names
2014-01-08 16:56:32 +00:00
Douglas Meehan
a1abc9bb8a
edited class names
2014-01-08 16:54:41 +00:00
Douglas Meehan
b529e576ff
added geo support for PassThroughManager
2014-01-08 16:46:39 +00:00
Curtis
6f30e88ba5
Attempt to carry over extras(select) values from parent
2014-01-08 23:46:00 +11:00
Carl Meyer
87f7209042
Bump version for dev.
2014-01-06 18:26:01 -07:00
Carl Meyer
6b4a900ca0
Bump version to 2.0.
2014-01-06 18:22:24 -07:00
Carl Meyer
5e39bcd756
Remove special support for pickling PassThroughManager; apparently unnecessary in all supported Django/Python versions.
2014-01-06 18:18:42 -07:00
Carl Meyer
32aa781dc2
Merge branch 'master' into query-set-deprecated
...
* master:
Update tox.ini.
Update runtests.py for compatibility with Django 1.7.
Check for StatusModel field name conflicts correctly.
2014-01-06 16:06:31 -07:00
Carl Meyer
8ea75e53f4
Check for StatusModel field name conflicts correctly.
2014-01-06 16:03:44 -07:00
Thomas Schreiber
910bcc7830
backwards comptatible get_queryset, for Django < 1.6
2013-12-31 17:30:11 +01:00