Commit Graph

422 Commits (3d9587acfb24959a2cc88f6fc1520a617be9c00f)

Author SHA1 Message Date
Diederik van der Boor 65de1f74ab Added PolymorphicManager.from_queryset() to properly set the queryset 2016-02-17 12:36:48 +01:00
Diederik van der Boor 3bab378b25 Bump version to 0.9 2016-02-17 12:28:01 +01:00
Diederik van der Boor 14a5417891 Added yet another hack to keep the child admin site happy.
This really validates a different solution to the child admin layout,
e.g. by registering the models in the regular admin site.
2016-02-17 12:27:33 +01:00
Diederik van der Boor efdebb1575 Fix missing redirect for the history_view.
This fixes django-reversion, and partally django-reversion-compare.
2016-02-17 11:20:11 +01:00
Diederik van der Boor 01a35cfe95 Fix Django 1.9 handling of custom URLs.
The new change-URL redirect overlapped any custom URLs defined in the child admin.
This makes sure the redirect doesn't interfere with custom URLs.
2016-02-17 11:20:11 +01:00
Diederik van der Boor 4277c148aa Merge pull request #161 from theatlantic/pr-add-deferred-fields
Add support for qset.only() and qset.defer()
2016-02-17 11:14:48 +01:00
slide333333 9b7c2d72b7 Added test cases for complex expressions in aggregate/annotate 2016-01-21 15:32:28 +01:00
slide333333 c5d4687bb9 Support Django 1.8 complex expressions on aggregate/annotate 2016-01-21 13:21:21 +01:00
Frankie Dintino 6df1403de5 Add support for qset.only() and qset.defer() 2016-01-04 00:36:48 -05:00
gilgamezh b17aa58ad9 Merge remote-tracking branch 'upstream/master' into allow_extra_manager 2015-12-29 17:49:09 -03:00
Diederik van der Boor e9f549758f Bump version to 0.8.1 2015-12-29 14:55:25 +01:00
Diederik van der Boor b0657ef9c7 Fix reverse relation support for ___ filter operator 2015-12-29 14:52:58 +01:00
Diederik van der Boor 009069a32b Avoid auto-proxying all methods to the queryset.
This is unwanted behavior, and django provides much better methods for
it instead. (PolymorphicQuerySet.as_manager() / PolymorphicManager.from_queryset()
2015-12-28 17:10:58 +01:00
Diederik van der Boor 9e2c11beb8 Replace __version__.py with __init__.py
Also fixes reporting in sentry.
2015-12-28 17:10:42 +01:00
Diederik van der Boor 5191b6c130 Also remove showfields imports from __init__.py
If we're to cause pain, let it be once.
2015-12-28 17:10:42 +01:00
Diederik van der Boor 50f21dfa43 Rename manager.py => managers.py for consistency 2015-12-28 17:10:42 +01:00
Diederik van der Boor 07242d210f Fix "Model" __ "_field" query support
Broken by 24e6b21204 for Django 1.9
upgrade
2015-12-28 16:19:27 +01:00
Diederik van der Boor b7431b2d06 Fix PEP8 block comment issues (E265) 2015-12-28 15:16:42 +01:00
Diederik van der Boor aaf06c71a5 Fix PEP8 whitespace issues
autopep8 -r polymorphic/ example/ -i
--select=E112,E113,E115,E116,E122,E123,E125,E127,E128,E201,E202,E203,E211,E225,E226,E227,E228,E231,E251,E261,E262,E271,E272,E273,E274,E301,E302,E303,E304,E309,E711,E713,W291,W293,W391
--exclude migrations,south_migrations

(line conditiation fixes: E123,E125,E122,E127,E128)
2015-12-28 15:16:29 +01:00
gilgamezh f419e37ab3 Allow to set a 'extra' custom manager withut override the _default_manager 2015-12-23 21:07:44 -03:00
Jonas Haag 4da67a0fb6 Fix an issue with '.values()' queries 2015-12-16 10:31:36 -03:00
Jonas Haag 0b87a5ecc8 Fixed a Python >= 3.7 incompatibility (see PEP 479) 2015-12-16 10:31:36 -03:00
Jonas Haag ee2e0a95ea Extend comment about admin URL patching 2015-12-16 10:31:36 -03:00
Hugo Osvaldo Barrera fb32b97b37 Remove obsolete compatibility code comment 2015-12-16 10:31:36 -03:00
Hugo Osvaldo Barrera e73a4662c3 Prevent infinite redirection on django1.9
See here[1] as to why this is an issue, and why we can skip the avoided
code on django>=1.9.

[1]: https://docs.djangoproject.com/en/1.9/releases/1.9/#django-contrib-admin
2015-12-16 10:31:36 -03:00
Jonas Haag 6cf187b2de Fix Django < 1.8 compatibility 2015-12-16 10:31:36 -03:00
Jonas Haag 24e6b21204 Fix a handful of warnings and remove some unused compatibility code 2015-12-16 10:31:36 -03:00
Hugo Osvaldo Barrera adcad20b48 Update all tests (and runtests.py) 2015-12-16 10:31:36 -03:00
Hugo Osvaldo Barrera b996d1c377 Avoid broken references to declared_fieldset
Check if this attribute exists first, since it does not in recent django
versions.
2015-12-16 10:31:33 -03:00
Hugo Osvaldo Barrera ad5ce60158 Remove reference to obsolete request.REQUEST 2015-10-21 22:27:00 -03:00
Hugo Osvaldo Barrera 31bfe8d1e7 Remove deprecated django.conf.urls.patterns 2015-10-21 22:18:21 -03:00
Hugo Osvaldo Barrera c48d4f589b Don't import models and managers in __init__
This is deprecated as of django 1.8, and does not work as of django 1.9.
2015-10-21 22:11:06 -03:00
Gavin Wahl 0c940bd795 SingleRelatedObjectDescriptor was renamed in Django 1.9 2015-10-13 13:22:13 -06:00
Gonzalo Bustos 83eec48d27 add spanish translation 2015-10-12 11:44:01 -03:00
Diederik van der Boor c8973d1fba Fixed Python 2.6 tests, and fixed tox.ini from PR #162 for python 3 2015-10-01 14:35:34 +02:00
Diederik van der Boor ce4b9348ec Bump version to 0.7.2 to release a few minor bugfixes 2015-10-01 14:26:28 +02:00
Diederik van der Boor 2ffbd51844 Added as_manager() support for querysets 2015-10-01 14:26:28 +02:00
Diederik van der Boor d85664f0b7 Optimize PolymorphicModel attribute access, only use __getattribute__ hack when needed. 2015-10-01 14:03:33 +02:00
Diederik van der Boor fdf905d91b Merge pull request #156 from svleeuwen/patch-1
Fix Pickle exception when polymorphic model is cached
2015-10-01 14:02:12 +02:00
Tai Lee bcc39a9086 Raise Http404 if object does not exist. 2015-09-22 09:55:03 +10:00
Sander van Leeuwen ed55ceb7fa Fix Pickle exception when polymorphic model is cached
fixes issue #155
2015-09-04 16:51:22 +02:00
Diederik van der Boor 1979ee6079 Remove unused import after merging #139 2015-08-04 16:13:06 +02:00
Martin Maillard 941e447ed0 Use parent admin site class for child admin site
Using the ``AdminSite`` class directly can cause issues when the parent
model is registered with a custom admin site class.
2015-06-08 14:04:26 +02:00
Diederik van der Boor 7a29c3972c Bump version to 0.7.1 2015-04-30 11:40:14 +02:00
Diederik van der Boor 1ff5f148b6 Fixed Django 1.8 support for related field widgets.
The RelatedFieldWidgetWrapper tries to resolve the "change" url with
"__fk__" as ID value, which broke with our strict pk_regex
2015-04-30 11:39:13 +02:00
Diederik van der Boor 9d68dee7dd __version__.py: reference PEP 440 instead. 2015-04-30 11:35:34 +02:00
Diederik van der Boor 07e1ff90a8 Bump versions to 0.7 2015-04-08 14:08:47 +02:00
Diederik van der Boor 5f4e6e18ba Fix missing import 2015-04-08 13:49:10 +02:00
tyaslab 135feaf905 fixed 'source_expressions'
(cherry picked from commit 9a34a2a5017499bb12512b2387de49aa2c40fc88)
2015-04-08 13:44:35 +02:00
Diederik van der Boor 640461216b Merge pull request #127 from warrd/master
Issue with related_name in polymorphic_ctype field
2015-04-08 13:40:28 +02:00
Diederik van der Boor 9ef7ccb65e Fixed long/int issue for Python 3.
This closes #126 with a fix that won't degrate Python 2 code.
2015-04-08 13:38:26 +02:00
Diederik van der Boor 9efc5cfcb2 Merge pull request #124 from benkonrath/fix-admin-500-error
Don't remove '/' from id when it's not in the path
2015-04-08 13:35:25 +02:00
Diederik van der Boor 17c2445e39 Merge pull request #120 from theatlantic-pr/cleanup-test-noise
Conflicts:
	polymorphic/tests.py
2015-04-08 13:33:54 +02:00
Diederik van der Boor 2b78b92cc6 Merge pull request #121 from luisza/master
Fixed preserved filter for django 1.7
2015-04-08 13:25:17 +02:00
Diederik van der Boor c947c3dec1 Merge pull request #119 from theatlantic/child-model-custom-pk-bug
Bug with queryset results on base model where child model has a custom primary key
2015-04-08 13:09:35 +02:00
Diederik van der Boor d16d989e91 Merge pull request #118 from theatlantic/_default_manager-instance-fix
Set _default_manager directly on model_cls; don't use add_to_class()
2015-04-08 13:06:12 +02:00
Nick Ward 90933184e9 Modified polymorphic_ctype related_name to be valid 2015-03-11 16:33:19 +00:00
Ben Konrath 2a8a16edb8 Don't remove '/' from id when it's not in the path 2015-03-02 11:24:50 +01:00
Luis Zárate 727df8bd3d Fixed preserved filter for django 1.7
The problem occurs when you have a filter and create o delete a child, when is back to change list
the filter is lost, and have a e=-1 as a get parameter
2015-02-09 08:15:42 -06:00
Frankie Dintino 1be1fc02db Fix missing items bug in qset on child of PolymorphicModel w custom pk
fixes #66
2015-01-31 17:11:03 -05:00
Frankie Dintino ad63c6a442 Test missing items bug in qset on child of PolymorphicModel w custom pk
refs #66
2015-01-31 17:10:57 -05:00
Frankie Dintino fd24863db5 Cleanup tests by removing spurious errors and unnecessary noise
- Remove diamond inheritance tests since these test a bug in Django,
  not in django_polymorphic.
- Fix spurious print message in test_primary_key_custom_field_problem(),
  where uuid instances are for some reason being compared to uuid.UUID
  classes. Replaced with a test that checks that the primary key values
  are valid UUIDs.
- Remove Django > 1.6 conditionals wrapping the multiple inheritance
  tests and model definitions, in favor of using the definitions for
  Django 1.7. Django 1.7 requires a custom primary key when using concrete
  model inheritance because failing to do so is potentially ambiguous. Adding
  the custom primary key does not break tests in older Django versions.
2015-01-31 16:59:55 -05:00
Frankie Dintino a3d9379876 Set _default_manager directly on model_cls; don't use add_to_class()
Using model_cls.add_to_class() calls Manager.contribute_to_class(),
which then sets the attribute to an instance of ManagerDescriptor. In
the case of _default_manager, this behavior differs from Django's, as
_default_manager is set to the manager instance itself, not its
descriptor. This is why it is normally possible to access default_manager
from a model instance.

fixes #96
2015-01-31 13:17:56 -05:00
Chris Barna d56d9bfd15 Add tests for instance._default manager. Refs #96 2015-01-31 13:17:56 -05:00
ellmetha 469d063cc9 Django 1.8 alpha support 2015-01-28 00:41:34 +01:00
Diederik van der Boor ca6fba91ba PEP8-ify PR #67 and fix trailing whitespace
Camp rule: leave things in a better state then you found it.
2014-12-30 13:36:25 +01:00
Diederik van der Boor 261e382556 Merge pull request #67 from hottwaj/parent_link_support
parent_link and related_name support for inheritance fields
2014-12-30 13:34:16 +01:00
Diederik van der Boor 4d526d8780 Simplify selecting get_queryset() vs get_query_set() -> use self.all() 2014-12-30 13:25:22 +01:00
Diederik van der Boor 4bddac7c70 Fix validate_model_fields(), caused errors when metaclass raises errors 2014-10-29 18:58:54 +01:00
Diederik van der Boor aead57c037 Fix Django 1.4/1.5 issues with RelatedManager code that overrides get_query_set()
Make sure the `RelatedManager.get_query_set()` is called, which limits
the set, instead of calling `self.get_queryset()` which then returns a new queryset.

Fortunately, this only happened on proxied calls for unknown methods.
2014-10-16 16:07:17 +02:00
Diederik van der Boor 6d043d35d2 Bump version to 0.6.1 already 2014-10-14 17:32:40 +02:00
Diederik van der Boor 948749dbdb Remove Django 1.7 warnings 2014-10-14 17:30:25 +02:00
Diederik van der Boor c9e232a79b Bump version to 0.6 2014-10-14 16:29:30 +02:00
Diederik van der Boor 84791daf47 Merge pull request #99 from benkonrath/admin_class_permissions
Use admin class function to check permissions.
2014-09-22 16:03:55 +02:00
Diederik van der Boor 981614e5c6 Merge branch 'django_1.7_support' of https://github.com/g3rd/django_polymorphic
Conflicts:
	docs/managers.rst
	polymorphic/admin.py
	polymorphic/manager.py
	polymorphic/tests.py
	runtests.py
2014-09-22 15:42:35 +02:00
Diederik van der Boor ff6b09e7c7 admin: split get_queryset() / queryset() methods.
avoid calling loops due to some inherited classes
2014-09-22 15:14:32 +02:00
Diederik van der Boor cf6d2a4a41 Replace get_query_set with assignment.
Avoid calling the super class by accident, potentially causing loops.
Follow the django-mptt approach here.
2014-09-22 15:00:29 +02:00
Diederik van der Boor ea160669cf Merge pull request #91 from mlsen/master
Django 1.8 compatibility
2014-09-22 14:51:03 +02:00
Chad Shryock cc53b3003e Remove exception. 2014-09-17 08:30:12 -04:00
Chad Shryock b9654b7138 Missing return. 2014-09-17 08:26:28 -04:00
Chad Shryock 734752c2e7 Django 1.7 upgrades 2014-09-16 22:11:13 -04:00
Ben Konrath 6aa9d7cc3a Use admin class function to check permissions. 2014-09-11 15:18:40 +02:00
Chad Shryock af4843e54b Cleared up the Django 1.8 Warning messages. 2014-09-10 23:13:51 -04:00
Ben Konrath ec5ce49d81 Use consistent labels in admin. 2014-08-04 15:05:13 +02:00
Diederik van der Boor 14df8c529e Move the get_permission_codename import to the main code.
cc #93
2014-07-29 12:15:09 +02:00
Kevin Armenat 029bb2ae1a added django < 1.6 compatibilty for permission codename generation 2014-07-29 11:15:38 +02:00
Kevin Armenat 6ce390f777 added permission check for all child types 2014-07-29 09:47:23 +02:00
Marius Lueck d755d257ef Changed super call of get_queryset to queryset 2014-07-25 22:55:58 +02:00
Marius Lueck fb1795ad12 Fixed compatibility with django 1.8 2014-07-25 11:48:07 +02:00
Diederik van der Boor 831075c3c7 bump version to 0.5.6 2014-07-21 11:42:26 +02:00
Jacob Rief 62e7940c33 Fixed: adding polymoric model with django-parler did not work 2014-07-18 18:26:51 +02:00
Diederik van der Boor d8b40167d3 Mention the improvements of #87 in the changelog and documentation too. 2014-07-08 17:18:07 +02:00
Andrew d8d6f07f71 Adds pk_regex attr in PolymorphicParentModelAdmin 2014-07-08 18:05:04 +03:00
Diederik van der Boor 8a548ca829 bump version to 0.5.5 2014-04-29 14:11:58 +02:00
Diederik van der Boor b9d7e9f234 Improved description of test_proxy_get_real_instance_class unit test
Camp life rule: leave things better then you found them.
2014-04-29 14:07:33 +02:00
John Furr 8687e135a3 Test that proxy models derived from PolyMorphicBase classes
can call get_real_instance() and get_real_instance_class()

Includes:
def test_proxy_get_real_instance_class(self):
2014-04-29 07:35:27 -04:00
John Furr f85ebdd9e6 Fix get_real_instance_class for proxy models 2014-04-28 11:32:30 -04:00
utapyngo e1a4ba80e9 Fixed typo: CopntentType 2014-04-18 19:17:23 +07:00
Diederik van der Boor 6c58acac8d bump version and changelog 2014-04-09 12:11:29 +02:00
Diederik van der Boor 35cdb7b697 Fix subclass protection when ContentType is stale 2014-04-07 14:38:34 +02:00
Diederik van der Boor e8d5ce6231 Add protection against mixed up ContentType tables 2014-04-04 15:28:47 +02:00
Diederik van der Boor b5774423f7 Improve on #69, using setdefault() and update example project
Camp site rule; leave things tidier than you found them :)
2014-04-03 14:27:56 +02:00
Diederik van der Boor 08e900eb6d Merge pull request #69 from borgstrom/django16
Prevent infinite recursion in Django 1.6
2014-04-03 14:24:52 +02:00
Diederik van der Boor 157f6b1057 Fix missing ``alters_data = True`` annotations. 2014-04-03 14:10:53 +02:00
Evan Borgstrom d93add71fb Be more specific in the condition before setting 'fields' 2014-03-13 16:50:25 -04:00
Evan Borgstrom 134c44bef0 Prevent infinite recursion in Django 1.6 2014-03-13 16:39:13 -04:00
hottwaj 02221d7d10 changed dict.iteritems() call to dict.items() for python 3 compatibility... 2014-02-19 11:05:57 +00:00
hottwaj 578aa8f1dd removed pdb import which I used for testing... 2014-02-19 11:00:19 +00:00
hottwaj fd0ed96c1a Fixed bugs in superclass/subclass field link processingso that this can cope with proxy models, as well as parent_link and related_name links to parents.
Added a test case for testing parent_link and related_name links to parent.

All tests pass should pass now (at least they do for me on django 1.5 and python 2.7)
2014-02-19 10:56:02 +00:00
hottwaj 3e718d305e Changed methods used for traversing subclasses and superclasses of a given model.
Now uses model._meta.parents to determine superclasses.  _meta.parents is a dict of superclass: field_to_superclass pairs.

By using the field name of field_to_superclass, we can work out the field to use the django_polymorphic accessor on, even if a user-specified OneToOneField to parent is is used (with parent_link=True) to get to the parent in the inheritance hierarachy.

For subclasses, the path to the subclasses can be manually specified by the user if they use a 'related_name' on the OneToOneField from the subclass to the superclass.  I have changed the code to also support 'related_name' if present
2014-02-18 18:00:18 +00:00
Diederik van der Boor 4be6d42fad Optimize NewBase test of six.with_metaclass() for Django 1.5+ 2014-02-13 10:43:33 +01:00
Bertrand Bordage ed708c69c6 Adds a french translation. 2013-11-29 18:18:55 +01:00
Diederik van der Boor e1093ff1fb Fix .non_polymorphic(), returns a copy of the queryset
Just like .filter() and such do.
2013-09-19 19:36:05 +02:00
Diederik van der Boor 61e9a8050a Bump version to 0.5.3 2013-09-17 11:33:56 +02:00
Diederik van der Boor a8d27ca94e Pass ``/admin/app/model/ID/...`` URLs to the correct admin backend.
Using the ID field, the correct ``ct_id`` parameter can already be
determined.
2013-09-17 11:02:38 +02:00
Diederik van der Boor e0446bd76c Fix TypeError when ``base_form`` was not defined. 2013-09-17 10:50:46 +02:00
Diederik van der Boor b622d6f6a1 Bump version to 0.5.2 2013-09-05 11:38:26 +02:00
Diederik van der Boor 638ecd5813 Fix admin validation errors related to additional non-model form fields. 2013-09-05 11:36:54 +02:00
Diederik van der Boor b2be0701ca Fix missing permission check in the "add type" view.
The permissions were checked in the next step,
so this didn't cause a security issue.
2013-08-20 12:07:29 +02:00
Diederik van der Boor 9d00d214e1 Fix unwanted `___` handling when a fieldname starts with an underscore. 2013-07-22 10:21:00 +02:00
Diederik van der Boor d16f2d7590 Add changelog entry for Grappelli fix. 2013-07-18 21:17:00 +02:00
Bertrand Bordage 2421f10ab5 Simplifies the two remaining templates (for grappelli support). 2013-07-18 16:38:14 +02:00
Bertrand Bordage 40eeb15fad Simplifies add_type_form.html. See #38. 2013-06-07 13:39:33 +02:00
Gavin Wahl 1958146f10 Increase version and add django 1.6 support to the changelog 2013-05-24 15:37:01 -06:00
Gavin Wahl 7f2111c201 assertQuerysetEquals requires an ordered queryset 2013-05-24 15:17:44 -06:00
Gavin Wahl 71767431eb Django 1.6 support
CHUNK_SIZE has been removed from Django, so set it ourself if it can't
be imported.
2013-05-24 15:13:34 -06:00
Diederik van der Boor ff22332d2c Remove Django 1.1 compatibility switch 2013-05-20 23:54:45 +02:00
Diederik van der Boor fed810b336 Update version numbers for 0.5 release 2013-05-20 18:03:35 +02:00
Diederik van der Boor 83238697d2 Setup.py: update trove classifiers, read version from code. 2013-05-20 17:12:38 +02:00
Diederik van der Boor 4d7d33ed0d Port new code to Python 3 as well, fix six.with_metaclass() issues
Many thanks to @atheiste for the big porting steps!
2013-05-20 16:03:21 +02:00
Tomas Peterka cbf52a61af Porting to Python 3.2
Removed compatibility_tools (because we aim to Python 2.7 and Python 3.2)
Performed 2to3 and modified
Usage of django.utils.six which adds dependency on Django >= 1.4.2
2013-05-20 16:03:21 +02:00
Diederik van der Boor c933be9c24 Port documentation to Sphinx, cleanup README 2013-05-19 17:15:41 +02:00
Diederik van der Boor 8cf313335c Handle stale ContentType models (no longer referring to a model)
This builds on top of a fix in Django 1.6, and has a workaround for
Django 1.4 and 1.5. When the base class points to a model that no longer
exists, it will be silently dropped in the polymorphic queryset results.

This behavior is identical to iterating over results when the derived
table doesn't have the object anymore.
2013-05-19 14:35:29 +02:00
Chris Glass 8527244cb3 Bumped versio to .dev0 2013-04-10 14:23:29 +02:00
Chris Glass 7d562511ba Version 0.4.2 proper 2013-04-10 14:18:55 +02:00
Chris Glass 9b9838116d Bumped version to 0.4.2
Previous verison had a broken setup.py
2013-04-10 14:15:05 +02:00
Chris Glass 3a29da5133 Bumped version to 0.4.1 2013-04-10 14:11:06 +02:00
Chris Glass e38b7002f4 Merge branch 'master' of github.com:chrisglass/django_polymorphic 2013-04-10 14:10:15 +02:00
Chris Glass 9c5c6c5136 Made the version number logic saner 2013-04-10 14:09:46 +02:00
Diederik van der Boor 4106ad7296 Apply list filter in example app 2013-04-08 00:37:51 +02:00
floppya a214cd58f7 Adds admin list filter for polymorphic child models. 2013-04-08 00:35:55 +02:00
Adam Wentz 04dce421e5 Fixes PolymorphicQuerySet for django 1.6
QuerySet.dup_select_related has been removed.
2013-04-08 00:35:22 +02:00
Diederik van der Boor bb0a4daddc Optimize transmogrify() function, assign __class__ instead. 2013-04-08 00:32:06 +02:00
floppya 54cf2f37d8 Updated proxy model tests
Extracted classes from original proxy test.
Added another simple proxy model test.
Moved the test case to a seemingly better spot.
2013-04-08 00:32:06 +02:00
floppya 20ac209dbb Fixes proxy models in the admin
The PolymorphicParentModelAdmin was getting the concrete model ids for
the add form.
2013-04-08 00:32:06 +02:00
Jedediah Smith 1a6f3a45e5 Handle non-distinct results from base object query 2013-04-08 00:32:06 +02:00
Diederik van der Boor ea9cb91e78 Rename variables in polymorphic/query.py for clarity
(split from previous commit by @jedediah)
2013-04-08 00:32:06 +02:00
Diederik van der Boor 19d5ed2338 Fix base_manager unit test
As more methods are added to the PolymorphicModel, the attr dict changes
ordering in the meta class. By making the ordering of managers
consistent, this problem no longer occurs.
2013-04-08 00:32:02 +02:00
Jedediah Smith 58c4f6f697 Optimization - don't do extra queries for proxy models 2013-04-08 00:05:21 +02:00
floppya 74389bb23d Update for proxy models and Django 1.5
Only monkeypatch when using Django < 1.5
Updated test
2013-04-08 00:05:21 +02:00
Jedediah Smith e2cfbf3898 Support proxy models (still requires one query per proxied model, not optimal) 2013-04-07 23:36:09 +02:00
Diederik van der Boor 78253bfe12 Fix passing custom querysets to related managers.
* The custom manager was not assigned to _default_manager;
  get_first_user_defined_manager() always returned None
* The PolymorphicManager couldn't remember it's custom queryset;
  a RelatedManager creates a new instance of a manager, so the queryset
  parameter should be known at class-level, not object level.
* The old method of providing a custom queryset class has been deprecated.
2013-04-07 01:39:58 +02:00
Diederik van der Boor 1f26302632 Fix Django 1.5 support, tests pass again.
The reason polymorphic broke was because it couldn't find some managers
anymore in the inheritance tree. Django 1.5 removes these and replaces
them with an `AbstractManagerDescriptor`. This patch restores those objects
2013-04-07 00:43:41 +02:00
Diederik van der Boor ca4067e279 Add proxy model test that fails in Django 1.5 2013-04-05 17:36:50 +02:00
Chris Glass 62d97f29b1 Merge pull request #30 from vdboor/cleanup_for_15
Cleanup before porting to Django 1.5
2013-04-05 03:09:42 -07:00
Diederik van der Boor e411660b80 Tests: fix missed error in last commit
(cannot amend, already pushed for review)
2013-04-05 12:01:44 +02:00
Diederik van der Boor ebced5f4eb Tests: make old code more readable 2013-04-05 11:45:07 +02:00
Diederik van der Boor 7ca328f9e4 Tests: auto removed unused imports 2013-04-05 11:39:57 +02:00
Diederik van der Boor 2d83124f51 Tests: remove Django 1.1 compatibility check 2013-04-05 11:38:56 +02:00
Diederik van der Boor 25aa32d7bd Replaced the doctests with unit tests
Making debugging tests much easier. The same repr() logic is preserved,
so this is essentually a huge coding style change.
2013-04-05 11:33:41 +02:00
Diederik van der Boor 32426aa41a Use self.assertEqual() in tests instead of assert statement. 2013-04-05 09:54:48 +02:00
Julian Wachholz a6f8429aae django.conf.urls.defaults is deprecated; use django.conf.urls instead 2013-04-04 23:41:07 +03:00
Diederik van der Boor e7a2340723 Remove polymorphic_dumpdata command and assorted scripts.
The polymorphic_dumpdata command carried a deprecation note for a long
time now. The scripts for testing python versions are replaced by tox already.
2013-03-28 14:16:45 +01:00
Chris Glass 30172d3110 Merge pull request #24 from onepercentclub/port-regression-doctest-to-unit-test
Port regression doctest to unit test
2013-03-25 02:04:07 -07:00
Ben Konrath 8e4697c741 Port regression doctest to unit test. 2013-03-18 22:33:55 +01:00
Ben Konrath dc6f41c7e9 Update URLs to github hosted webpage. 2013-03-18 21:27:23 +01:00
Ben Konrath 318dd3d67a Fixed the default manager test failures.
According to the django docs (1.4 / 1.5), the default manager for subclasses of
PolymorphicModel should be PolymorphicManager:

3. The default manager on a class is either the first manager declared on the
   class, if that exists, or the default manager of the first abstract base
   class in the parent hierarchy, if that exists. If no default manager is
   explicitly declared, Django’s normal default manager is used.

https://docs.djangoproject.com/en/1.4/topics/db/managers/#custom-managers-and-model-inheritance
https://docs.djangoproject.com/en/1.5/topics/db/managers/#custom-managers-and-model-inheritance
2013-03-18 20:56:12 +01:00
Ben Konrath b718acf005 Update db_type method for Django >= 1.4 DB settings format. 2013-03-18 20:50:45 +01:00
Ben Konrath 1ef9e068df Import settings in tests from django.conf. 2013-03-18 20:47:56 +01:00
Diederik van der Boor 720a189f5a Remove unused load statements in add_type_form.html
This addresses Django 1.5 compatibility as well (see #16)
2013-03-18 12:15:10 +01:00
Diederik van der Boor f687dc18b1 SQL optimization, avoid query in pre_save_polymorphic()
This query is visible in the django-debug-toolbar POST redirect page
2012-11-15 10:42:02 +01:00
Diederik van der Boor 0d5f2fd943 Change the child model registration to fix raw_id_fields.
As discovered in django-polymorphic-tree and django-fluent-pages,
the raw_id_fields didn't work in Django 1.4 because the fields actively
check which models are actually registered in the admin site.

Hence, the parent admin site _registry is inserted in the child admin as
well. This also completely moves the initialisation of the child admin
into this class, using a `get_child_models()` function,
akin to the static `child_models` attribute.
2012-07-24 21:50:52 +02:00
Diederik van der Boor 0b608cc67e Minor extension: allow apps to override the type label in the add form easily
When overriding apps, this turns out to be a very useful feature to
have.
2012-07-18 00:51:34 +02:00
Diederik van der Boor 8d426d9243 Remove abc marker because methods are no longer abstract 2012-07-13 18:29:02 +02:00
Diederik van der Boor b2e308d30c Improve PolymorphicParentAdmin, simplify, fix templates
During the development of django-polymorphic-tree it was discovered that
the PolymorphicParentModelAdmin could actually be made much simpler.
It features a `child_models` attribute now, so there is very little code
needed to actually implement a polymorphic admin now.

Also found various issues which are together fixed in this commit for
pulling.
2012-07-13 16:01:58 +02:00
Diederik van der Boor 2e76811adb Adding PolymorphicChildModelAdmin to __all__ as well 2012-07-05 23:27:34 +02:00
Diederik van der Boor 5d65bf4bbc Added polymorphic admin interface
Extracted from django-fluent-pages, ready for other apps too.
The polymorphic admin is implemented via a parent admin for the base
model, and separate admin interfaces for the child models.

The parent model needs to inherit PolymorphicParentModelAdmin,
and override `get_admin_for_model()` and `get_child_model_classes()`
to find the child admin interfaces.

The derived models have their own `ModelAdmin` class, which inherits
from `PolymorphicChildModelAdmin`. The parent admin redirects it's
change and delete views to the child admin.

By adding `polymorphic` to the INSTALLED_APPS, the breadcrumbs will be
fixed as well, to remain unchanged between the child applications.
2012-07-05 23:16:46 +02:00
Jonas Obrist 870091c13f Explicit is better than implicit 2012-01-09 16:47:59 +01:00
German M. Bravo f987818fe4 PEP 8 cleaning
Conflicts:

	polymorphic/__init__.py
	polymorphic/polymorphic_model.py
2011-12-20 18:59:50 +00:00
German M. Bravo c9922d8987 PEP 8 cleaning 2011-12-20 18:59:50 +00:00
German M. Bravo bb06d6d12b Some more PEP 8 cleaning 2011-12-20 18:59:25 +00:00
Martin Brochhaus dfc8eff1e1 Not using attrs when getting the first user defined manager. 2011-12-09 15:22:38 +08:00
Chris Glass c7cbfc0e23 Removed dead imports. 2011-05-19 15:16:39 +02:00
Jonas Obrist 10b8901088 Edited polymorphic/showfields.py via GitHub 2011-05-19 06:08:39 -07:00
Jonas Obrist 30f11a35d7 Edited polymorphic/query_translate.py via GitHub 2011-05-19 06:07:25 -07:00
Jonas Obrist 6f8e31222d PEP-8, it's a thing! 2011-05-19 06:05:49 -07:00
Jonas Obrist ba2cb60c9d Edited polymorphic/polymorphic_model.py via GitHub 2011-05-19 06:04:23 -07:00
Jonas Obrist fabae70ed4 protip: after a colon in python, HIT THE ENTER KEY! 2011-05-19 06:02:53 -07:00
Jonas Obrist f42c58c0d4 it's python, not javascript! 2011-05-19 06:01:07 -07:00
Bert Constantin 2c47db8fcc Fixed github issue 15 (query result incomplete with inheritance). Thanks to John Debs. 2011-01-24 17:03:23 +01:00
Bert Constantin 3cc7d483c1 minor additions in base.py 2011-01-24 16:45:58 +01:00
Bert Constantin 4a4cfd82a2 translate_polymorphic_Q_object: fixed test case, and made the function a member of PolymorphicObject.
Minor test fixes: warnings fixed, test_tool.py renamed as it's no test
2010-11-12 07:19:23 +01:00
Bert Constantin f78b27dc1a updated docs, tests, misc 2010-11-02 12:21:46 +01:00
Bert Constantin 52f32c1fc3 improved showfields.py for better and more precise output, updated tests 2010-11-02 12:21:46 +01:00
Bert Constantin a4ac6cc91d fix object retrieval problem occuring with some custom primary key fields
+ added UUIDField as test case
2010-11-02 12:21:22 +01:00
Bert Constantin 6befe6c733 added "queryset.get_real_instances()" usage, added testcase 2010-11-02 12:10:02 +01:00
Bert Constantin 8c3df56cb6 non_polymorphic() queryset member function added 2010-10-23 12:22:13 +02:00
Bert Constantin 19adbdaf2c extra(): Re-implemented. Now is polymorphic (nearly) without restrictions.
Added test cases + docs.
2010-10-23 11:52:04 +02:00
Bert Constantin 6c8d28cbbc extra(): throw error if unsupported argument is encountered, support 'params' argument, special case Django 1.1 2010-10-22 13:37:26 +02:00
Abel Daniel 486a579ac7 Make .extra() only disable polymorphic query if an arg that is currently
not handled is actually used. I.e. if all args are supported, then
do polymorphic query by default.
2010-10-22 13:35:50 +02:00
Bert Constantin b2357592cb make sure 'base_manager is not inherited (but managed by Django instead).
(This seems more correct but it doen't seem to make any difference.)
Also added related test cases.
2010-10-22 13:35:39 +02:00
Bert Constantin 6628145af7 removed __getattribute__ hack from PolymorphicModel.
A somewhat cleaner solution is now used (through __init__) which
also completely removes the performance impact of __getattribute__.
2010-10-20 09:31:42 +02:00
Bert Constantin a87481b8b5 polymorphic_dumpdata management command functionality removed;
the regular Django dumpdata command now automatically works correctly
for polymorphic models and all Django versions
(this is handled by PolymorphicModelBase now).
Testing for dumpdata has been added.
2010-10-20 09:31:42 +02:00
Bert Constantin f05b854a54 make PolymorphicQuerySet.get_real_instances() an official part of the API 2010-10-20 09:31:42 +02:00
Bert Constantin b1905026bc Documentation updated.
Test_all_versions script added.
Some minor misc changes.
Added polybench.
2010-10-20 09:31:36 +02:00
Bert Constantin c10ff1650b added translate_polymorphic_Q_object 2010-10-19 21:28:33 +02:00
Bert Constantin 01bdb2f9b0 - renamed ShowField* to ShowFieldType, ShowFieldContent, ShowFieldTypeAndContent, in order to reflect better what they do.
- by default, django_polymorphic's pretty printing of querysets/objects (via ShowField*) is not used anymore
- ShowField mixins now also show the annotations (after the regular fields, prepended by "Ann:")
- cleaned up implementation.
2010-10-19 21:28:33 +02:00
mathieusteele 50b54f5aca removed requirement for primary key to be an IntegerField. 2010-10-14 19:14:58 -07:00
Bert Constantin 116e2af08b IMPORTANT: import path changed, it's now: "from polymorphic import PolymorphicModel, ..."
- added python2.4 compatibility. Contributed by Charles Leifer. Thanks!
- general reorganization of the code - there is no single polymorphic.py module anymore,
  so d-p now needs to be installed as a regular Django app
- polymorphic.VERSION/get_version added
- version numbering started: V0.5 beta
2010-02-22 16:16:00 +01:00
Bert Constantin e6c1e7ec6e fix "...has no attribute 'sub_and_superclass_dict'". Thanks to Mattias Brändström.
this occurred if a subclass defined __init__ and accessed class
members before calling the superclass __init__
(__getattribute__ had a problem, as "sub_and_superclass_dict" was set in __init__).
2010-02-18 20:18:49 +01:00
Bert Constantin 7e584632b8 fix unnecessary field-name/model-name conflicts (i.e. field_name == model_name.lower() )
=> __init__ + __getattribute__ now handle only the Django inheritance
references that are needed ('modela_ptr', 'modelc' etc.), avoiding
unnecessary conflicts with field names.
2010-02-18 20:05:17 +01:00
Bert Constantin 2795f7acd5 some doc + minor code updates (__repr__ + Show... mixins) 2010-02-18 20:04:38 +01:00
Bert Constantin 2fcb7fba1a queryset order_by method added, testcase, docs 2010-02-04 16:38:58 +01:00
Bert Constantin b4aeae417e queryset values(), values_list(), distinct() documented; defer(), only() allowed (but not yet supported) 2010-02-04 16:14:10 +01:00
Bert Constantin c10577c32f queryset aggregate() and extra() methods implemented, testcases, docs 2010-02-04 15:28:55 +01:00
Bert Constantin 9e7a78a8cb queryset annotate() method implemented, and testcase 2010-02-04 15:28:55 +01:00
Bert Constantin a99a3b5bfc fix remaining potential accessor name clashes (but this only works with Django 1.2+, for 1.1 no changes). Thanks to Andrew Ingram. 2010-02-04 15:28:49 +01:00
Bert Constantin ecaed2a71f fixed use of 'id', replaced with 'pk' 2010-02-04 15:13:44 +01:00
Bert Constantin 2e17a184c0 fix select_related bug for objects from derived classes (till now sel.-r. was just ignored) 2010-02-04 15:13:44 +01:00
Bert Constantin 2a740e9b10 doc- and minor code updates 2010-02-04 15:13:33 +01:00
Bert Constantin c7ac78e08d Fixed ContentType related field accessor clash (an error emitted by model validation),
by adding related_name to the ContentType ForeignKey. Thanks to  Andrew Ingram.
This happened if a polymorphc model used a ContentType ForeignKey.
Plus minor documentation updates.
2010-01-30 14:15:52 +01:00
Bert Constantin 8bdda93e76 Restructured django_polymorphic into a regular add-on application.
This is needed for the management commands, and also seems
to be a generally good idea for future viablity as well.
Also misc documentation updates.
2010-01-29 13:41:19 +01:00