mirror of
https://github.com/jazzband/django-admin2.git
synced 2026-04-28 18:44:48 +00:00
Added sample configuration to example app
This commit is contained in:
parent
121f5b8564
commit
78b063a586
1 changed files with 21 additions and 2 deletions
|
|
@ -1,12 +1,16 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Import your custom models
|
||||
from django.contrib.auth.models import Group, User
|
||||
from django.contrib import messages
|
||||
from django.utils.translation import ugettext_lazy
|
||||
|
||||
import djadmin2
|
||||
from djadmin2 import renderers
|
||||
from djadmin2.actions import DeleteSelectedAction
|
||||
|
||||
# Import your custom models
|
||||
from .actions import CustomPublishAction
|
||||
from .models import Post, Comment
|
||||
from .models import Post, Comment, Event, EventGuide
|
||||
|
||||
|
||||
class CommentInline(djadmin2.Admin2Inline):
|
||||
|
|
@ -25,7 +29,11 @@ class PostAdmin(djadmin2.ModelAdmin2):
|
|||
list_actions = [DeleteSelectedAction, CustomPublishAction, unpublish_items]
|
||||
inlines = [CommentInline]
|
||||
search_fields = ('title', '^body')
|
||||
list_filter = ['published', 'title']
|
||||
list_display = ('title', 'body', 'published')
|
||||
field_renderers = {
|
||||
'title': renderers.title_renderer,
|
||||
'published': renderers.boolean_renderer,
|
||||
}
|
||||
|
||||
|
||||
class CommentAdmin(djadmin2.ModelAdmin2):
|
||||
|
|
@ -33,6 +41,17 @@ class CommentAdmin(djadmin2.ModelAdmin2):
|
|||
list_filter = ['post', ]
|
||||
|
||||
|
||||
class EventAdmin(djadmin2.ModelAdmin2):
|
||||
list_display = ('date',)
|
||||
field_renderers = {
|
||||
'date': renderers.datetime_renderer,
|
||||
}
|
||||
|
||||
|
||||
# Register each model with the admin
|
||||
djadmin2.default.register(Post, PostAdmin)
|
||||
djadmin2.default.register(Comment, CommentAdmin)
|
||||
djadmin2.default.register(User, UserAdmin2)
|
||||
djadmin2.default.register(Group, GroupAdmin2)
|
||||
djadmin2.default.register(Event, EventAdmin)
|
||||
djadmin2.default.register(EventGuide)
|
||||
|
|
|
|||
Loading…
Reference in a new issue