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 728B

12345678910111213141516171819202122232425262728
  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. #external code customised
  7. #import from https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-the-existing-user-model
  8. #start ---
  9. class CustomUserInline(admin.StackedInline):
  10. model = CustomUser
  11. can_delete = False
  12. verbose_name_plural = 'customUsers'
  13. # Define a new User admin
  14. class UserAdmin(BaseUserAdmin):
  15. inlines = (CustomUserInline, )
  16. # Re-register UserAdmin
  17. admin.site.unregister(User)
  18. admin.site.register(User, UserAdmin)
  19. admin.site.register(Post)
  20. #end ---