Custom QuerySets

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
class Girls(models.Manager):
def get_query_set(self):
return super(Counter,self).get_query_set().filter(gender=1)
class Sample(models.Model):
objects = models.Manager()
girls = Girls()
name = models.CharField(max_length=30)
#######################################################
#view
@render_to('test.html')
def test(request):
lam = Sample.girls.all()
return {'lam':lam}