开发者

django admin custom list_filter: Is Null/Not Null choices

I have a model:

class Label ( TimeStampAwareModel ):
     name = models.CharField ( max_length = 255, blank = False )
     slug = models.CharField ( max_length = 255, blank = True, null =开发者_开发知识库 True ) 
     description = models.TextField () 
     logo = ImageField ( upload_to = 'images/labels', null=True, blank=True)

Now i want apply filter for logo, slug and desc. i found this, but i don't know how to apply it on my code?

is there anyone knows the other solution or tell me how to use this snippet? I am using django 1.3.

Thanks :)


in your admin.py do the following:

from django.contrib import admin

from project.app.models import Label // where project is your project name and app is your application name, you change this accordingly


class Label_Admin(admin.ModelAdmin):
    list_filter = ['slug', 'logo', 'description']

admin.site.register(Label, Label_Admin)

Thats all you need, hope this helps.

Edited

for custom filter please refer to this post.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜