Reputation: 37
users/models.py
class User(AbstractBaseUser, PermissionsMixin):
class Meta:
verbose_name_plural = "user"
user_nm = models.CharField(max_length=10)
user_email = models.EmailField( unique=True)
user_tel = models.CharField(
max_length=11, validators=[validate_user_tel]
)
user_ty = models.CharField(max_length=8)
users/admin.py
class UserAdmin(admin.ModelAdmin):
list_display = [
"id",
"user_nm",
"user_ty",
"user_tel",
"user_email",
"point_amt",
"user_join_dts",
]
There are two types of user models(user_ty) "P" and "G".
at the admin I want to divide categories by users "P" and "G" types. Will it be possible?
For example, an existing administrator is a capture. Each model in the board app is listed. What I want is to give the [user_ty] field in the user's app "G" and "P" respectively, just like each model.
Upvotes: 0
Views: 155
Reputation: 108
In order to show the same model twice in Django admin, you need to use the proxy model, something like this [enter link description here][1] and then you can show the model in admin based on condition like this [enter link description here][2]
[1]: https://books.agiliq.com/projects/django-admin-cookbook/en/latest/add_model_twice.html#:~:text=%C2%B6,only%20the%20read%20only%20admin.) [2]: Django Admin Display row if a variable is true
Upvotes: 1