Revision created by MOE tool push_codebase.
[gae.git] / python / lib / django_1_4 / tests / regressiontests / custom_managers_regress / models.py
blob3c4e621769d3ea78f99061b0ec6413d848da3df7
1 """
2 Regression tests for custom manager classes.
3 """
5 from django.db import models
8 class RestrictedManager(models.Manager):
9 """
10 A manager that filters out non-public instances.
11 """
12 def get_query_set(self):
13 return super(RestrictedManager, self).get_query_set().filter(is_public=True)
15 class RelatedModel(models.Model):
16 name = models.CharField(max_length=50)
18 def __unicode__(self):
19 return self.name
21 class RestrictedModel(models.Model):
22 name = models.CharField(max_length=50)
23 is_public = models.BooleanField(default=False)
24 related = models.ForeignKey(RelatedModel)
26 objects = RestrictedManager()
27 plain_manager = models.Manager()
29 def __unicode__(self):
30 return self.name
32 class OneToOneRestrictedModel(models.Model):
33 name = models.CharField(max_length=50)
34 is_public = models.BooleanField(default=False)
35 related = models.OneToOneField(RelatedModel)
37 objects = RestrictedManager()
38 plain_manager = models.Manager()
40 def __unicode__(self):
41 return self.name