admin.py 930 B

1234567891011121314151617181920212223242526272829
  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. exclude = ('w_publier','w_reading',)
  15. filter_horizontal = ('w_cat',)
  16. actions = [bt_w_publier, bt_w_not_publier]
  17. search_fields = ['w_titre','w_contenu']
  18. admin.site.register(Wiki, Wiki_Admin)
  19. class Cat_Wiki_Admin(admin.ModelAdmin):
  20. list_display = ('cw_titre', 'cw_titre_slgify')
  21. pass
  22. admin.site.register(Cat_Wiki, Cat_Wiki_Admin)