Filtering model results for Django admin select box
Posted
by blcArmadillo
on Stack Overflow
See other posts from Stack Overflow
or by blcArmadillo
Published on 2010-06-15T18:14:07Z
Indexed on
2010/06/15
18:52 UTC
Read the original article
Hit count: 410
I just started playing with Django today and so far am finding it rather difficult to do simple things. What I'm struggling with right now is filtering a list of status types. The StatusTypes model is:
class StatusTypes(models.Model):
status = models.CharField(max_length=50)
type = models.IntegerField()
def __unicode__(self):
return self.status
class Meta:
db_table = u'status_types'
In one admin page I need all the results where type = 0 and in another I'll need all the results where type = 1 so I can't just limit it from within the model. How would I go about doing this?
© Stack Overflow or respective owner