Source

django-basic-events / events / admin.py

from django.contrib import admin
from django.core.urlresolvers import reverse

from events.forms import EventAdminForm
from events import models

class EventCategoryAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug', )
    search_fields = ('name',)
    prepopulated_fields = {'slug': ('name',)}
admin.site.register(models.EventCategory, EventCategoryAdmin)


class AttachmentAdmin(admin.ModelAdmin):
    list_display = ('file', 'name', 'slug', 'order')
    search_fields = ('file', 'name', 'slug')
admin.site.register(models.Attachment, AttachmentAdmin)


class EventAdmin(admin.ModelAdmin):
    list_display = ('name', 'begin_date', 'is_upcoming',
                    'is_published', 'show_date',)
    list_filter = ('begin_date', 'is_published',
                   'show_date',)
    search_fields = (
        'name',
        'description',
    )
    ordering = ('-begin_date',)
    date_hierarchy = 'begin_date'
    prepopulated_fields = {'slug': ('name',)}
    fieldsets = (
        (None, {
            'fields': (
                'name',
                'slug',
                'begin_date',
                'end_date',
                'description',
                'location',
                'address',
                'is_published',
                'show_date',
            ),
        }),
        ('Attachments', {
            'fields': (
                'attachments',
            ),
        }),
        ('Categories', {
            'fields': (
                'categories',
            ),
        }),
    )
    form = EventAdminForm
admin.site.register(models.Event, EventAdmin)