Commit graph

126 commits

Author SHA1 Message Date
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
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
Keryn Knight
8a1d0662f1 Provide dir() support for PassThroughManagers.
Reported in #55 by erikcw.
2014-04-15 08:48:01 +01: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
Seán Hayes
3f7378ef60 Allow PassThroughManager subclasses to accept additional params. 2014-03-07 06:32:34 -05: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
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
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
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
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
5e39bcd756 Remove special support for pickling PassThroughManager; apparently unnecessary in all supported Django/Python versions. 2014-01-06 18:18:42 -07:00
Thomas Schreiber
910bcc7830 backwards comptatible get_queryset, for Django < 1.6 2013-12-31 17:30:11 +01:00
Thomas Schreiber
5ae92dba27 fix get_query_set deprecationwarnings 2013-12-30 21:42:52 +01:00
Keryn Knight
a270eef1fd Fixed #59 - manually setting the parent relation
via a OneToOne should present the same behaviour
as the implicit ptr Django generates on
subclasses.

Thanks to Eran Rundstein for reporting the issue
and proposing the fix.
2013-10-26 15:53:15 +01:00
Carl Meyer
06d3b7a5cf Tweak line-continuation indentation. 2013-10-22 12:23:16 -06:00
Keryn Knight
1de58474c0 Implemented #44 - passing Model classes to InheritanceManager's select_subclasses 2013-10-21 21:47:58 +01:00
Travis Swicegood
9111843752 Refactor to make sure get_subclass() is on QuerySet
There's an edge case where you might want to call get_subclass() on a
QuerySet the same way you can call get() after you have already called
various filter/exclude methods.
2013-10-07 18:15:41 -05:00
Carl Meyer
4b6a800050 Fix bug with child/grandchild select_subclasses in Django 1.6+; thanks Keryn Knight. 2013-09-20 10:04:10 -06:00
Andy Freeland
7e381179e4 PassThroughManager calls superclass get_query_set.
As discussed in #31, PassThroughManager and
PassThroughManager.for_queryset_class() would ignore the superclass
version of `get_query_set`.
2013-05-26 16:04:47 -04:00
Alex Orange
1e84465276 Test and fix for second grandchild bug.
Bug is, second grandchild of a given child will get cast to the child
rather then the grandchild.
2013-05-21 14:23:23 -06: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
Carl Meyer
579abf8e66 Fix calling create() on a related manager based on PassThroughManager. 2013-02-12 14:05:31 -07:00
Carl Meyer
cf2c97b620 Avoid overriding prior calls to select_related in select_subclasses. 2013-02-01 22:53:11 -07:00
Carl Meyer
93a1a44ee7 Updates to multi-level support for InheritanceManager. 2013-02-01 22:38:14 -07:00
Ivan Virabyan
937b3e018f Support for multi-level inheritance in InheritanceManager 2013-01-31 18:27:16 +04:00
Carl Meyer
246fb81813 Revert addition of UpdateOrCreateMixin; reaches 100% test coverage. 2013-01-27 14:16:58 -08:00
Carl Meyer
983fab0341 Clean up some uses of hasattr; no need to support 1.1 any longer. 2013-01-27 13:41:03 -08:00
Carl Meyer
6ae66e0153 Removed a bunch of deprecated code. 2013-01-27 13:30:31 -08:00
Carl Meyer
f7f54a03b0 Enable pickling PassThroughManager in Django 1.5. 2013-01-26 22:10:14 -08:00
Carl Meyer
a76006a3b2 Merge UpdateOrCreateMixin. 2013-01-26 17:20:52 -08:00
Carl Meyer
05f1dc97b3 Set use_for_related_fields=True on QueryManager. 2013-01-26 17:09:16 -08:00
Carl Meyer
ec1870c98a Merge pull request #19 from DXist/master
Extra deny methods for PassThroughManager
2013-01-26 17:05:15 -08:00
Carl Meyer
aa8c79eeb4 More straightforward, efficient implementation for InheritanceQuerySet. 2013-01-26 16:46:51 -08:00
Carl Meyer
8808aa05b8 Merged in jgsogo/django-model-utils (pull request #5)
patch to issue #16
2013-01-26 16:40:26 -08:00
Rinat Shigapov
e9e57e096f deny methods for queryset copy 2012-11-08 12:24:17 +04:00
Javier García Sogo
575a5e1340 avoid plain except 2012-11-05 13:43:42 +01:00
Carl Meyer
2376c931ab Update PassThroughManager docstring to match README docs; thanks atreanor. 2012-09-27 09:48:04 -06:00
Antti Kaihola
21371e3ea4 Added missing imports for UpdateOrCreateMixin 2012-08-27 15:21:52 +03:00
Javier Garcia Sogo
6ab6da083c patch to issue#16 2012-07-06 22:12:58 +02:00
Antti Kaihola
c83c14c46f Added an UpdateOrCreateMixin for creating custom managers and querysets which have an .update_or_create() method (see Django ticket #3182). 2012-06-08 16:47:28 +03:00
Carl Meyer
4746180c4d Improved fix for annotations and InheritanceQuerySet. Thanks Facundo Gaich. 2012-01-03 16:47:33 -07:00
Carl Meyer
c35746a445 Fixed annotation of InheritanceQuerySets. Thanks Jeff Elmore. 2012-01-03 15:47:41 -07:00
Carl Meyer
8c6af71713 Updated PassThroughManager.for_queryset_class for less ambiguous behavior in case of incorrect usage. 2011-12-05 17:08:51 -07:00
Ryan Kaskel
6afa9d566d Add convenience method to PassThroughManager. 2011-12-04 13:57:16 +00:00
smacker
9ac5877d29 add get_subclass method 2011-10-26 12:01:37 +06:00
Carl Meyer
5c5abdce23 Added use_for_related_fields=True to InheritanceManager. Fixes #8. Thanks munhitsu for the report.
Note that the tests added for this feature pass even without the change to
InheritanceManager, because use_for_related_fields is broken in Django and
always acts as if True for reverse FKs and M2Ms.
(http://code.djangoproject.com/ticket/14891)
2011-04-16 16:19:55 -05:00
Carl Meyer
69d0985db1 Started deprecation for manager_from, InheritanceCastModel, and Django 1.1 support. 2011-04-16 14:51:14 -05:00
Carl Meyer
7c19b761e2 Merged in fix for Django 1.1 recursion error from Paul McLanahan. 2011-03-30 10:20:37 -04:00
Paul McLanahan
d8798fb784 Fixed a recursion error in Django 1.1 2011-03-29 21:57:49 -04:00
Carl Meyer
36b99304c2 Merged in PassThroughManager from Paul McLanahan. 2011-03-29 13:10:50 -04:00
zyegfryed
ae64c23b39 Fixed related subclasses parsing. Was raising AttributeError on FileField. 2011-03-29 14:59:50 +02:00
Paul McLanahan
04c848e8c7 Added tests for PassThroughManager. 2011-03-09 14:44:10 -05:00
Paul McLanahan
c624d7a301 Added PassThroughManager to managers.
Added me to authors.
2011-03-08 13:52:32 -05:00
Carl Meyer
ac36cbf56c Added InheritanceManager, contributed by Jeff Elmore. 2010-11-23 12:48:23 -05:00
Carl Meyer
396dd9274f use manager_from for inheritance-casting 2010-10-05 09:01:26 -04:00
Gregor Müllegger
216db6c098 Creating a custom QuerySet subclass for InheritanceCastModel to provide a way to batch cast a queryset of parents into child types. It's (2 + m) queries instead of (1 + n * 2) now (n: number of returned objects, m: number of different types in the queryset). 2010-10-01 20:43:22 +02:00
Carl Meyer
5da38ee0c6 manager_from bugfix from George Sakkis; fixes #1 2010-08-16 17:58:16 -04:00
Carl Meyer
afafdd2bf9 make manager_from Django 1.1 compatible 2010-07-30 22:45:45 -04:00
Carl Meyer
aed583f763 added manager_from (thanks George Sakkis) 2010-07-30 22:09:46 -04:00
Carl Meyer
7703512c7f 0.3.0
--HG--
extra : convert_revision : carl%40dirtcircle.com-20090730211136-ywu7dfqfmsodkc1x
2009-07-30 17:11:36 -04:00