admin.py 444 B

1234567891011121314151617
  1. from django.contrib import admin
  2. from bitfield import BitField
  3. from bitfield.forms import BitFieldCheckboxSelectMultiple
  4. from .models import APIToken
  5. class APITokenAdmin(admin.ModelAdmin):
  6. raw_id_fields = ("user",)
  7. list_display = ("token", "user", "label")
  8. readonly_fields = ("token",)
  9. formfield_overrides = {
  10. BitField: {"widget": BitFieldCheckboxSelectMultiple},
  11. }
  12. admin.site.register(APIToken, APITokenAdmin)