Merge pull request #417 from felixxm/issue-base-manager

Used Meta.base_manager_name on model instead of Manager.use_for_related_fields.
This commit is contained in:
Dirk Eschler 2017-06-27 09:33:39 +02:00 committed by GitHub
commit 2b4149dc0e
2 changed files with 11 additions and 3 deletions

View file

@ -7,6 +7,7 @@ https://github.com/zmathew/django-linguo
"""
import itertools
import django
from django.db import models
from django.db.models import FieldDoesNotExist
try:
@ -570,7 +571,8 @@ class MultilingualQuerysetManager(models.Manager):
class MultilingualManager(MultilingualQuerysetManager):
use_for_related_fields = True
if django.VERSION < (1, 10):
use_for_related_fields = True
def rewrite(self, *args, **kwargs):
return self.get_queryset().rewrite(*args, **kwargs)

View file

@ -194,8 +194,12 @@ def add_manager(model):
else:
class NewMultilingualManager(MultilingualManager, manager.__class__,
MultilingualQuerysetManager):
use_for_related_fields = getattr(
manager.__class__, "use_for_related_fields", not has_custom_queryset(manager))
if VERSION < (1, 10):
use_for_related_fields = getattr(
manager.__class__,
"use_for_related_fields",
not has_custom_queryset(manager),
)
_old_module = manager.__module__
_old_class = manager.__class__.__name__
@ -224,6 +228,8 @@ def add_manager(model):
# share the same class.
model._default_manager.__class__ = current_manager.__class__
patch_manager_class(model._base_manager)
if VERSION >= (1, 10):
model._meta.base_manager_name = 'objects'
if hasattr(model._meta, "_expire_cache"):
model._meta._expire_cache()