Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

admin.py 573B

123456789101112131415161718192021222324
  1. from django.contrib import admin
  2. from django.contrib.auth import get_user_model
  3. from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
  4. from django.contrib.auth.models import User
  5. from .models import Post, CustomUser
  6. class CustomUserInline(admin.StackedInline):
  7. model = CustomUser
  8. can_delete = False
  9. verbose_name_plural = 'customUsers'
  10. # Define a new User admin
  11. class UserAdmin(BaseUserAdmin):
  12. inlines = (CustomUserInline, )
  13. # Re-register UserAdmin
  14. admin.site.unregister(User)
  15. admin.site.register(User, UserAdmin)
  16. admin.site.register(Post)