admin.py 475 B

123456789101112131415161718192021
  1. from django.contrib import admin
  2. from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
  3. from django.contrib.auth.models import User
  4. from .models import Profile
  5. # 定义一个行内admin
  6. class ProfileInline(admin.StackedInline):
  7. model = Profile
  8. can_delete = False
  9. verbose_name_plural = 'UserProfile'
  10. class UserAdmin(BaseUserAdmin):
  11. inlines = (ProfileInline,)
  12. # 重新注册User
  13. admin.site.unregister(User)
  14. admin.site.register(User, UserAdmin)