comparison gpp/forums/admin.py @ 552:9e42e6618168

For bitbucket issue #2, tweak the admin settings for the Post model to reduce slow queries. Define our own queryset() method so we can control the select_related(), and not have it cascade from post to topics to forums to categories. Removed 'topic' from list_display because MySQL still sucked with 2 inner joins. Now it seems to be tolerable with only one join to User.
author Brian Neal <bgneal@gmail.com>
date Wed, 25 Jan 2012 20:07:03 -0600
parents 79d454ff2de0
children 98b373ca09f3
comparison
equal deleted inserted replaced
551:f37ef598fecc 552:9e42e6618168
38 list_filter = ('creation_date', 'update_date', ) 38 list_filter = ('creation_date', 'update_date', )
39 save_on_top = True 39 save_on_top = True
40 40
41 41
42 class PostAdmin(admin.ModelAdmin): 42 class PostAdmin(admin.ModelAdmin):
43 list_display = ('topic', 'user', 'creation_date', 'update_date', 'summary') 43 list_display = ('user', 'creation_date', 'update_date', 'user_ip', 'summary')
44 raw_id_fields = ('topic', 'user', ) 44 raw_id_fields = ('topic', 'user', )
45 exclude = ('html', ) 45 exclude = ('html', )
46 search_fields = ('body', ) 46 search_fields = ('body', )
47 date_hierarchy = 'creation_date' 47 date_hierarchy = 'creation_date'
48 list_filter = ('creation_date', 'update_date', ) 48 list_filter = ('creation_date', 'update_date', )
49 ordering = ('-creation_date', ) 49 ordering = ('-creation_date', )
50 save_on_top = True 50 save_on_top = True
51
52 def queryset(self, request):
53 return Post.objects.select_related('user')
51 54
52 55
53 class FlaggedPostAdmin(admin.ModelAdmin): 56 class FlaggedPostAdmin(admin.ModelAdmin):
54 list_display = ['__unicode__', 'flag_date', 'get_post_url'] 57 list_display = ['__unicode__', 'flag_date', 'get_post_url']
55 actions = ['accept_flags'] 58 actions = ['accept_flags']