Merge branch 'master' into travis-tox

fix_request_path_info
Diederik van der Boor 2017-04-26 15:42:03 +02:00 committed by GitHub
commit 6ec29b9e5e
3 changed files with 62 additions and 39 deletions

View File

@ -92,7 +92,6 @@ matrix:
env: TOXENV="djangodev"
allow_failures:
- env: TOXENV="django111"
- env: TOXENV="djangodev"
before_install:

View File

@ -1,4 +1,4 @@
.. image:: https://travis-ci.org/django-polymorphic/django-polymorphic.png?branch=master
.. image:: https://travis-ci.org/django-polymorphic/django-polymorphic.svg?branch=master
:target: http://travis-ci.org/django-polymorphic/django-polymorphic
.. image:: https://img.shields.io/pypi/v/django-polymorphic.svg
:target: https://pypi.python.org/pypi/django-polymorphic/

View File

@ -25,6 +25,25 @@ except ImportError:
Polymorphic_QuerySet_objects_per_request = CHUNK_SIZE
if django.VERSION >= (1, 9):
# We ignore this on django < 1.9, as ModelIterable didn't yet exist.
from django.db.models.query import ModelIterable
class PolymorphicModelIterable(ModelIterable):
def __iter__(self):
base_iter = super(PolymorphicModelIterable, self).__iter__()
if self.queryset.polymorphic_disabled:
for o in base_iter:
yield o
return
real_instances = self.queryset._get_real_instances(base_iter)
for obj in real_instances:
yield obj
def transmogrify(cls, obj):
"""
Upcast a class to a different type without asking questions.
@ -72,6 +91,9 @@ class PolymorphicQuerySet(QuerySet):
# to that queryset as well).
self.polymorphic_deferred_loading = (set([]), True)
super(PolymorphicQuerySet, self).__init__(*args, **kwargs)
if django.VERSION >= (1, 9):
# On django < 1.9 we override the iterator() method instead
self._iterable_class = PolymorphicModelIterable
def _clone(self, *args, **kwargs):
# Django's _clone only copies its own variables, so we need to copy ours here
@ -407,6 +429,8 @@ class PolymorphicQuerySet(QuerySet):
return resultlist
if django.VERSION < (1, 9):
# On django 1.9+, we can define self._iterator_class instead of iterator()
def iterator(self):
"""
This function is used by Django for all object retrieval.