admin.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from django.contrib import admin
  2. from django.contrib.auth.admin import UserAdmin as UA
  3. from django.utils.translation import gettext_lazy as _
  4. from .models import User, UserInstitution
  5. @admin.register(User)
  6. class UserAdmin(UA):
  7. fieldsets = (
  8. (None, {"fields": ("password",)}),
  9. (_("Personal info"), {"fields": ("first_name", "last_name", "email")}),
  10. (
  11. _("Permissions"),
  12. {
  13. "fields": (
  14. "is_active",
  15. "is_staff",
  16. "is_superuser",
  17. "groups",
  18. "user_permissions",
  19. ),
  20. },
  21. ),
  22. (_("Important dates"), {"fields": ("last_login", "date_joined")}),
  23. )
  24. add_fieldsets = (
  25. (
  26. None,
  27. {
  28. "classes": ("wide",),
  29. "fields": ("email", "password1", "password2"),
  30. },
  31. ),
  32. )
  33. list_display = ("email", "first_name", "last_name", "is_staff")
  34. ordering = ("-is_staff",)
  35. readonly_fields = ("last_login", "date_joined")
  36. @admin.register(UserInstitution)
  37. class UserInstitutionAdmin(admin.ModelAdmin):
  38. pass