Mercurial > public > madeira
comparison gigs/admin.py @ 128:6c7dd8bda890
For Django 1.6: ModelAdmin.queryset renamed to get_queryset.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 24 Dec 2013 14:59:35 -0600 |
parents | e2868ad47a1e |
children |
comparison
equal
deleted
inserted
replaced
127:1fd79e3b47e2 | 128:6c7dd8bda890 |
---|---|
14 class CityAdmin(admin.ModelAdmin): | 14 class CityAdmin(admin.ModelAdmin): |
15 list_display = ['name', 'state', 'country'] | 15 list_display = ['name', 'state', 'country'] |
16 list_filter = ['state'] | 16 list_filter = ['state'] |
17 search_fields = ['name'] | 17 search_fields = ['name'] |
18 | 18 |
19 def queryset(self, request): | 19 def get_queryset(self, request): |
20 qs = super(CityAdmin, self).queryset(request) | 20 qs = super(CityAdmin, self).get_queryset(request) |
21 return qs.select_related('state', 'country') | 21 return qs.select_related('state', 'country') |
22 | 22 |
23 | 23 |
24 class StateAdmin(admin.ModelAdmin): | 24 class StateAdmin(admin.ModelAdmin): |
25 inlines = [CityInline] | 25 inlines = [CityInline] |
28 class VenueAdmin(admin.ModelAdmin): | 28 class VenueAdmin(admin.ModelAdmin): |
29 list_filter = ['city__name'] | 29 list_filter = ['city__name'] |
30 list_display = ['name', 'city'] | 30 list_display = ['name', 'city'] |
31 search_fields = ['name'] | 31 search_fields = ['name'] |
32 | 32 |
33 def queryset(self, request): | 33 def get_queryset(self, request): |
34 qs = super(VenueAdmin, self).queryset(request) | 34 qs = super(VenueAdmin, self).get_queryset(request) |
35 return qs.select_related('city', 'city__state', 'city__country') | 35 return qs.select_related('city', 'city__state', 'city__country') |
36 | 36 |
37 | 37 |
38 class BandAdmin(admin.ModelAdmin): | 38 class BandAdmin(admin.ModelAdmin): |
39 search_fields = ['name'] | 39 search_fields = ['name'] |
42 class GigAdmin(admin.ModelAdmin): | 42 class GigAdmin(admin.ModelAdmin): |
43 list_filter = ['date'] | 43 list_filter = ['date'] |
44 save_on_top = True | 44 save_on_top = True |
45 filter_horizontal = ['bands'] | 45 filter_horizontal = ['bands'] |
46 | 46 |
47 def queryset(self, request): | 47 def get_queryset(self, request): |
48 qs = super(GigAdmin, self).queryset(request) | 48 qs = super(GigAdmin, self).get_queryset(request) |
49 return qs.select_related('venue') | 49 return qs.select_related('venue') |
50 | 50 |
51 | 51 |
52 admin.site.register(Band, BandAdmin) | 52 admin.site.register(Band, BandAdmin) |
53 admin.site.register(City, CityAdmin) | 53 admin.site.register(City, CityAdmin) |