Ticket #11895: admin.py

File admin.py, 2.5 KB (added by patrick@…, 15 years ago)

example of defining apps for different admin-sites

Line 
1from django.contrib import admin
2
3admin.site.apps = [
4 {
5 'name': 'User Management',
6 'classes': 'collapse-closed',
7 'show_apps': True,
8 'apps': ['auth', 'user', 'registration']
9 },
10 {
11 'name': 'Main Content',
12 'classes': 'collapse-closed',
13 'show_apps': True,
14 'apps': ['movies', 'stars']
15 },
16 {
17 'name': 'Special Content',
18 'classes': 'collapse-closed',
19 'show_apps': False,
20 'apps': ['festivals']
21 },
22 ...
23]
24
25from www.movies.models import Movie, MovieTip
26from www.movies.admin import MovieOptions, MovieTipOptions
27
28from www.stars.models import Star, StarNews, StarInterview, StarCredit
29from www.stars.admin import StarOptions, StarNewsOptions, StarInterviewOptions, StarCreditOptions
30
31from www.trailer.models import Trailer, TrailerItem, TrailerMobile
32from www.trailer.admin import TrailerOptions, TrailerMobileOptions
33
34from www.gallery.models import Gallery, GalleryItem
35from www.gallery.admin import GalleryOptions
36
37from www.festivals.models import SpecialScreening, SpecialScreeningSet, SpecialScreeningSetItem
38from www.festivals.models import Award, AwardSet, AwardSetItem
39from www.festivals.models import Festival, FestivalSet, FestivalSetItem
40from www.festivals.admin import SpecialScreeningOptions, SpecialScreeningSetOptions, AwardOptions, AwardSetOptions, FestivalOptions, FestivalSetOptions
41
42main_site = admin.AdminSite()
43main_site.register(Movie, MovieOptions)
44main_site.register(MovieTip, MovieTipOptions)
45main_site.register(Star, StarOptions)
46main_site.register(StarNews, StarNewsOptions)
47main_site.register(StarInterview, StarInterviewOptions)
48main_site.register(StarCredit, StarCreditOptions)
49main_site.register(Trailer, TrailerOptions)
50main_site.register(TrailerMobile, TrailerMobileOptions)
51main_site.register(Gallery, GalleryOptions)
52main_site.register(SpecialScreening, SpecialScreeningOptions)
53main_site.register(SpecialScreeningSet, SpecialScreeningSetOptions)
54main_site.register(Award, AwardOptions)
55main_site.register(AwardSet, AwardSetOptions)
56main_site.register(Festival, FestivalOptions)
57main_site.register(FestivalSet, FestivalSetOptions)
58
59main_site.apps = [
60 {
61 'name': 'Main Content',
62 'classes': '',
63 'show_apps': True,
64 'apps': ['movies', 'stars']
65 },
66 {
67 'name': 'Special Content',
68 'classes': '',
69 'show_apps': False,
70 'apps': ['festivals']
71 },
72 {
73 'name': 'Relational Content',
74 'classes': '',
75 'show_apps': True,
76 'apps': ['trailer', 'gallery']
77 }
78]
Back to Top