mirror of
https://github.com/jazzband/django-eav2.git
synced 2026-03-16 22:40:26 +00:00
Remove default 'objects' manager when appending EntityManager.
This commit is contained in:
parent
ac6dcc80c3
commit
57252d09d0
2 changed files with 55 additions and 2 deletions
47
.gitignore
vendored
47
.gitignore
vendored
|
|
@ -6,3 +6,50 @@
|
|||
_build
|
||||
build
|
||||
django_eav.egg-info/*
|
||||
env/
|
||||
|
||||
# -*- mode: gitignore; -*-
|
||||
*~
|
||||
\#*\#
|
||||
/.emacs.desktop
|
||||
/.emacs.desktop.lock
|
||||
*.elc
|
||||
auto-save-list
|
||||
tramp
|
||||
.\#*
|
||||
|
||||
# Org-mode
|
||||
.org-id-locations
|
||||
*_archive
|
||||
|
||||
# flymake-mode
|
||||
*_flymake.*
|
||||
|
||||
# eshell files
|
||||
/eshell/history
|
||||
/eshell/lastdir
|
||||
|
||||
# elpa packages
|
||||
/elpa/
|
||||
|
||||
# reftex files
|
||||
*.rel
|
||||
|
||||
# AUCTeX auto folder
|
||||
/auto/
|
||||
|
||||
# cask packages
|
||||
.cask/
|
||||
dist/
|
||||
|
||||
# Flycheck
|
||||
flycheck_*.el
|
||||
|
||||
# server auth directory
|
||||
/server/
|
||||
|
||||
# projectiles files
|
||||
.projectile
|
||||
|
||||
# directory configuration
|
||||
.dir-locals.el
|
||||
|
|
@ -119,12 +119,18 @@ class Registry(object):
|
|||
'''
|
||||
Attach the manager to *manager_attr* specified in *config_cls*
|
||||
'''
|
||||
# save the old manager if the attribute name conflict with the new one
|
||||
# Save the old manager if the attribute name conflict with the new one.
|
||||
if hasattr(self.model_cls, self.config_cls.manager_attr):
|
||||
mgr = getattr(self.model_cls, self.config_cls.manager_attr)
|
||||
self.config_cls.old_mgr = mgr
|
||||
|
||||
# attache the new manager to the model
|
||||
# Remove default 'objects' manager.
|
||||
for i, manager in enumerate(self.model_cls._meta.local_managers):
|
||||
if manager.name == 'objects':
|
||||
del self.model_cls._meta.local_managers[i]
|
||||
self.model_cls._meta._expire_cache()
|
||||
|
||||
# Attach the new manager to the model.
|
||||
mgr = EntityManager()
|
||||
mgr.contribute_to_class(self.model_cls, self.config_cls.manager_attr)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue