1 2 3 4 5 6 7 8 9 10 11 12 13 14 | class Article(models.Model):
site = models.ForeignKey(Site)
title = models.CharField(max_length=100)
body = models.TextField()
pub_date = models.DateTimeField()
class Admin:
# In this example, the Admin's object list will show *only* Articles
# which are related to the current Site.
# However, you could specify any Manager you like:
# manager = MyCustomManager()
from django.contrib.sites.managers import CurrentSiteManager
manager = CurrentSiteManager()
|
More like this
- User manager by diverman 2 years, 10 months ago
- Limit ForeignKey filter values to those that have a relationship with current model by overclocked 1 year, 6 months ago
- SSL Middleware for Webfaction by parlar 5 years ago
- showing environment variables in the django admin by tonemcd 2 years, 4 months ago
- Allow filtering and ordering by counts of related query results by exogen 5 years, 1 month ago
Comments
This does not work in Django 1.1 where you don't use the Admin class but where you have ModelAdmin class registered separately.
#