admin.py 891 B

123456789101112131415161718192021222324252627
  1. from import_export.admin import ImportExportModelAdmin
  2. from django.contrib import admin
  3. from wiki.models import *
  4. def bt_w_publier(modeladmin, request, queryset):
  5. queryset.update(w_publier=True)
  6. bt_w_publier.short_description = "Passer en Public"
  7. def bt_w_not_publier(modeladmin, request, queryset):
  8. queryset.update(w_publier=False)
  9. bt_w_not_publier.short_description = "Passer en Priver"
  10. class Wiki_Admin(ImportExportModelAdmin):
  11. form = Wiki_Admin_Form
  12. list_display = ('w_titre', 'w_description', 'w_publier','w_publdate','w_reading')
  13. list_filter = ('w_publier','w_cat','w_publdate')
  14. filter_horizontal = ('w_cat',)
  15. actions = [bt_w_publier, bt_w_not_publier]
  16. search_fields = ['w_titre','w_contenu']
  17. admin.site.register(Wiki, Wiki_Admin)
  18. class Cat_Wiki_Admin(admin.ModelAdmin):
  19. list_display = ('cw_titre', 'cw_titre_slgify')
  20. pass
  21. admin.site.register(Cat_Wiki, Cat_Wiki_Admin)