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

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