-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from adepue/master
Use correct Manager structure
- Loading branch information
Showing
3 changed files
with
13 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,20 @@ | ||
from django.db import models | ||
|
||
from .querysets import LiveGeoQuerySet | ||
|
||
|
||
LiveGeoManagerBase = models.Manager.from_queryset(LiveGeoQuerySet) | ||
|
||
|
||
class LiveGeoManager(LiveGeoManagerBase): | ||
class LiveGeoManagerBase(models.Manager): | ||
# To also use this manager for FK lookups, see | ||
# https://docs.djangoproject.com/en/1.6/topics/db/managers/#manager-types. | ||
|
||
def __init__(self, include_soft_deleted=False, *args, **kwargs): | ||
self.include_soft_deleted = include_soft_deleted | ||
super(LiveGeoManager, self).__init__(*args, **kwargs) # pylint: disable=super-on-old-class | ||
super(LiveGeoManagerBase, self).__init__(*args, **kwargs) # pylint: disable=super-on-old-class | ||
|
||
def get_queryset(self): | ||
qs = super(LiveGeoManager, self).get_queryset() # pylint: disable=super-on-old-class | ||
qs = super(LiveGeoManagerBase, self).get_queryset() # pylint: disable=super-on-old-class | ||
if not self.include_soft_deleted: | ||
return qs.live() | ||
return qs | ||
|
||
|
||
LiveGeoManager = LiveGeoManagerBase.from_queryset(LiveGeoQuerySet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters