I need to create several types of users with different permissions.
I’m trying to do so using proxy, but I’m not sure how to identify the resulting instances. I know that using proxy the models are in the same table in the DB, but I need to be able to identify them. For instance in the MyUser list in the admin I have all the instances created from User and MyUser model, and I’d like to have only MyUser instances.
I guess I should override the queryset method in MyUser admin, but I’m not sure what’s the best way to identify MyUser instances, or even if it’s the right way to have several user models with different permissions.
Anybody could help?
models.py
from django.db import models
from django.contrib.auth.models import User
class MyUser(User):
class Meta:
proxy = True
admin.py
class MyUserAdmin(admin.ModelAdmin):
pass
admin.site.register(MyUser, MyUserAdmin)
I created a group
myusers, and add it to the instance when creating aMyUserobject, so that I can filter them out inMyAdminUserqueryset: