Advertisement
Guest User

Untitled

a guest
May 21st, 2011
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.66 KB | None | 0 0
  1. #models.py
  2. class Foo(Model):
  3.     ...
  4.  
  5. class FooModerating(Foo):
  6.     '''
  7.        Прокси-модель
  8.    '''
  9.     class Meta:
  10.         proxy = True
  11.         app_label = 'moderating'
  12.  
  13. #admin.py
  14. class FooModeratingAdmin(admin.ModelAdmin):
  15.  
  16.     actions = ['make_moderated']
  17.  
  18.     def make_moderated(modeladmin, request, queryset):
  19.         queryset.update(is_moderated = True)
  20.     make_moderated.short_description = u'Отметить промодерированными'
  21.  
  22.     def queryset(self, request):
  23.         return Foo.objects.exclude(is_moderated = True)
  24.  
  25. admin.site.register(Foo, FooAdmin)
  26. admin.site.register(FooModerating, FooModeratingAdmin)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement