You are not logged in.

Change Language:

Profile for zygmunt

Name zygmunt
Email Address n/a
Posts1
  • Filtering
    Board » Django Standard Library » Admin
    Hi
    How can i create filter for active group?
    My models:
    class ArtGroup(models.Model):
    	title = models.CharField(max_length=150)
    	active = models.BooleanField()
    	def __unicode__(self):
    		return self.title
    
    class Art(models.Model):
    	title = models.CharField(max_length=150)
    	group = models.ForeignKey(ArtGroup)
    	text = models.TextField()
    	def __unicode__(self):
    		return self.title
    

    My admin model:
    class ArtAdmin(admin.ModelAdmin):
    	search_fields = ['title']
    	list_filter = ['group']
    

    This code doesn't works;-/:
    method in class Art
    def active_groups(self):
    	return ArtGroup.objects.filter(active=True)
    

    filter in ArtAdmin:
    	list_filter = ['active_groups']
    


Powered by Sphene Community Tools