mirror of
https://github.com/django/django.git
synced 2025-08-27 22:14:33 +00:00
Added django.contrib.sites.managers, which contains CurrentSiteManager. Thanks, Ian Holsman
git-svn-id: http://code.djangoproject.com/svn/django/trunk@2959 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
e3839f32e5
commit
a9039dc6b3
1 changed files with 11 additions and 0 deletions
11
django/contrib/sites/managers.py
Normal file
11
django/contrib/sites/managers.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
from django.db import models
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
class CurrentSiteManager(models.Manager):
|
||||||
|
"Use this to limit objects to those associated with the current site."
|
||||||
|
def __init__(self, field_name='site')
|
||||||
|
super(SiteLimitManager, self).__init__()
|
||||||
|
self.__lookup = field_name + '__id__exact'
|
||||||
|
|
||||||
|
def get_query_set(self):
|
||||||
|
return super(SiteLimitManager, self).get_query_set().filter(self.__lookup=settings.SITE_ID)
|
Loading…
Add table
Add a link
Reference in a new issue