from django.contrib import admin

from django.contrib.auth import get_user_model
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.models import User

from .models import Post, CustomUser


#external code customised
#import from https://docs.djangoproject.com/en/dev/topics/auth/customizing/#extending-the-existing-user-model
#start ---
class CustomUserInline(admin.StackedInline):
    model = CustomUser
    can_delete = False
    verbose_name_plural = 'customUsers'


# Define a new User admin
class UserAdmin(BaseUserAdmin):
    inlines = (CustomUserInline, )


# Re-register UserAdmin
admin.site.unregister(User)
admin.site.register(User, UserAdmin)
admin.site.register(Post)
#end ---