Skip to content

Commit

Permalink
add manager name
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Kahn committed Aug 17, 2016
1 parent 4fcddf1 commit 7ecadc9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 2 additions & 7 deletions django_sharding_library/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,8 @@ def configure(cls):
try:
if not isinstance(cls.objects, ShardManager):
if type(cls.objects) == Manager:
to_add = ShardManager()
to_add.name = 'shard_manager'
cls.add_to_class('objects', to_add)
if django.VERSION >= (1, 10):
cls._meta.base_manager = cls.objects
cls._meta.add_manager(to_add)
else:
cls.add_to_class('objects', ShardManager())
if django.VERSION < (1, 10):
cls._base_manager = cls.objects
else:
raise ShardedModelInitializationException('You must use the default Django model manager or'
Expand Down
5 changes: 5 additions & 0 deletions django_sharding_library/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ def create(self, **kwargs):

class ShardManager(Manager):

def __init__(self, *args, **kwargs):
return_value = super(ShardManager, self).__init__(*args, **kwargs)
self.name = 'shard_manager'
return return_value

def get_query_set(self, key=None):
# todo: (eventually, not necessary now) Should check to make sure the there is a good kwarg OR an instance ->
# available here
Expand Down

0 comments on commit 7ecadc9

Please sign in to comment.