Add tags support in admin
This commit is contained in:
parent
3a24fbdc28
commit
e94436c79c
1 changed files with 6 additions and 2 deletions
|
|
@ -5,14 +5,18 @@ from .models import Gallery, Photo, Tag
|
|||
|
||||
|
||||
class GalleryAdmin(admin.ModelAdmin):
|
||||
list_display = ('title', 'date_start', 'photo_count')
|
||||
list_filter = ['date_start']
|
||||
list_display = ('title', 'date_start', 'photo_count', 'get_tags')
|
||||
list_filter = ['date_start', 'tags']
|
||||
date_hierarchy = 'date_start'
|
||||
prepopulated_fields = {'slug': ('title',)}
|
||||
model = Gallery
|
||||
autocomplete_fields = ['photos', 'tags']
|
||||
search_fields = ['title', ]
|
||||
|
||||
def get_tags(self, obj):
|
||||
return ", ".join([t.name for t in obj.tags.all()])
|
||||
get_tags.short_description = _('tags')
|
||||
|
||||
|
||||
class PhotoAdmin(admin.ModelAdmin):
|
||||
list_display = ('title', 'date_taken', 'date_added',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue