Home > Enterprise >  Django admin not showing users after user customization
Django admin not showing users after user customization

Time:07-02

I customized my user authentication. Using Django 3.

In models.py I have;

class User(AbstractUser):
    is_patient = models.BooleanField(default=False)
    is_dentist = models.BooleanField(default=False)
    is_manager = models.BooleanField(default=False)

In views.py I have below for user creation and login;

def create_account_dentist(request):
if request.method == 'POST':
    #Create Dentist Type User
    username = request.POST.get('username')    
    password = request.POST.get('password')
    mobile_num = request.POST.get('mobilenum')
    user_profile = User()        
    user_profile.username = username
    user_profile.email = username
    user_profile.set_password(password)
    user_profile.is_dentist = True
    user_profile.is_staff = True
    user_profile.is_active = True
    user_profile.mobile_number = mobile_num
    user_profile.save()
    login(request, user_profile)
    return redirect(reverse('dentist-section'))

My sttings.py : AUTH_USER_MODEL = 'myapp.User'

When i check /admin page i see only groups section.

enter image description here

But i want to see the users, permissions and user groups together.

My DB tables are :

auth_group, auth_group_permissions, auth_permission, django_admin_log, django_content_type, django_migrations, django_session, myapp_dentist, myapp_manager, myapp_patient, myapp_user, myapp_user_groups, myapp_user_user_permissions

Although i created users in myapp_user, i dont see and manage them in django admin page

Below is screeshot from myapp_user table :

enter image description here

CodePudding user response:

You can check the admin.py file which is under the user's model folder, isn't it contain the admin.site.register(YUOR_MODEL_NAME) ,if you want to view the data in /admin page must have registered.

from django.contrib import admin
from YOUR_APP_NAME.models import User


admin.site.register(User)
  • Related