mirror of
https://github.com/Hopiu/django-modeltranslation.git
synced 2026-05-09 05:44:42 +00:00
Fix creation_counter on the patched managers in order to ensure the original local managers are prioritised over the inherited managers.
This commit is contained in:
parent
e69eb7b07e
commit
33f0ca9f62
1 changed files with 6 additions and 0 deletions
|
|
@ -203,11 +203,17 @@ def add_manager(model):
|
|||
if model._meta.abstract:
|
||||
return
|
||||
# Make all managers local for this model to fix patching parent model managers
|
||||
added = set(model._meta.managers) - set(model._meta.local_managers)
|
||||
model._meta.local_managers = model._meta.managers
|
||||
|
||||
for current_manager in model._meta.local_managers:
|
||||
prev_class = current_manager.__class__
|
||||
patch_manager_class(current_manager)
|
||||
if current_manager in added:
|
||||
# Since default_manager is fetched by order of creation, any manager
|
||||
# moved from parent class to child class needs to receive a new creation_counter
|
||||
# in order to be ordered after the original local managers
|
||||
current_manager._set_creation_counter()
|
||||
if model._default_manager.__class__ is prev_class:
|
||||
# Normally model._default_manager is a reference to one of model's managers
|
||||
# (and would be patched by the way).
|
||||
|
|
|
|||
Loading…
Reference in a new issue