Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple managers for model #81

Open
M1ha-Shvn opened this issue Aug 17, 2018 · 1 comment
Open

Multiple managers for model #81

M1ha-Shvn opened this issue Aug 17, 2018 · 1 comment

Comments

@M1ha-Shvn
Copy link

Hi. I've had a problem creating multiple managers for single model:

from django_sharding_library.manager import ShardManager
from django.db.models import Model

class ManagerA(ShardManager):
    pass

class ManagerB(ShardManager):
    pass

class MyModel(Model):
    class Meta:
        app_label = 'api'

    manager_a = ManagerA()
    manager_b = ManagerB()

print(type(MyModel.manager_a), type(MyModel.manager_b))
# prints: <class 'ManagerA'> <class 'ManagerA'>

After a long research, I've found out that the reason is here. Setting name to None or setting different names for my managers resolve the problem. So, my question is - what is the reason you customize manager's name?

@JBKahn
Copy link
Owner

JBKahn commented Aug 18, 2018

I didn't do that, to be honest I was planning to remove that code in my next release. Maintaining that seems like a lot of overhead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants