Django-Portfolio / demenza_site / blog / admin.py

from django.contrib import admin

from blog.models import Blog, Post

class BlogAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ("name",)}
    list_display = ('active', 'name', 'description', 'user')
    list_display_links = ('name',)
    list_editable = ('active',)
    list_filter = ('modified', 'created', 'active')
    date_hierarchy = 'created'
    search_fields = ['name', 'description', 'user__username']

class PostAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ("title",)}
    list_display = ('active', 'title', 'excerpt', 'publish_at',)
    list_display_links = ('title',)
    list_editable = ('active',)
    list_filter = ('publish_at', 'modified', 'created', 'active')
    date_hierarchy = 'publish_at'
    search_fields = ['title', 'excerpt', 'body', 'blog__name', 'blog__user__username']
    fieldsets = (
        (None, {
            'fields': ('title', 'blog'),
        }),
        ('Publication', {
            'fields': ('active', 'publish_at'),
            'description': "Control <strong>whether</strong> and <strong>when</strong> a post is visible to the world.",
        }),
        ('Content', {
            'fields': ('excerpt', 'body', 'tags'),
        }),
        ('Optional', {
            'fields': ('slug',),
            'classes': ('collapse',),
        })
    )

admin.site.register(Blog, BlogAdmin)
admin.site.register(Post, PostAdmin)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.