I'm not sure that I understand exactly what you are trying to do, but if you have built-in user administration pages that work a little different for teacher users, then I believe that you just need to extend UserAdmin and override the queryset method.
class TeacherSpecificUserAdmin(UserAdmin): def queryset(self, request): if request.user.is_teacher(): return Teacher.objects.filter(pk=request.user.pk) return UserAdmin.queryset(self, request)
This will take care of Teacher’s refusal to edit or delete other entries, because if you look in the ModelAdmin code, the change_view and delete_view use the query returned by the queryset method to get the object changed or deleted.
One more setting is necessary, since the view used to change the password in UserAdmin does not use the same system as the others to get the object to change. Just override it in the new class:
... def user_change_password(self, request, id): if request.user.is_teacher() and request.user.pk != int(id):
After that, you just need to prevent Teachers from adding new users or deleting their own account. Do this either using the standard django permission framework , or by overriding the has_add_permission and has_delete_permission .
Look in the source code for ModelAdmin if you want more information (in contrib/admin/options.py ).
source share