In Django I have replaced the user model using (AbstractUser). Then in the admin panel area the fields are unordered. When generating a new user, the password is not encrypted, the user is saved with the password unencrypted. But then I can't access the admin panel. Returning error the username or password do not match.
In model.py
# from django.contrib.auth import get_user_model
from django.contrib.auth.models import AbstractUser
from django.db import models
# UserModel = get_user_model()
class UserAgent_mod(AbstractUser):
phone_number = models.CharField(
max_length=9,
blank=True,
null=True,
)
profile_image = models.ImageField(
upload_to='photos_user_agent',
)
manage_properties = models.ManyToManyField(
to='property_app.Property_mod',
related_name='manage_properties',
blank=True
)
def __str__(self):
return f'{self.first_name} {self.last_name}'
class Meta:
verbose_name='User Agent'
verbose_name_plural = 'Users Agents'
In admin.py
from django.contrib import admin
from django.contrib.auth import get_user_model
UserModel = get_user_model()
@admin.register(UserModel)
class UserAgentAdmin(admin.ModelAdmin):
list_display = (
'username',
'first_name',
'last_name',
'phone_number',
'email',
)
list_filter = (
'first_name',
'last_name',
)
in settings.py
AUTH_USER_MODEL= 'user_agent_app.UserAgent_mod'
put the following code in your admin.py file: