Thursday, September 10, 2015

Re: Hide specific users from auth user model for non super users

I solve this overrite a UserAdmin class of admin.ModelAdmin:

from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from django.utils.translation import ugettext, ugettext_lazy as _
from django.core.exceptions import PermissionDenied


class UserAdmin(admin.ModelAdmin):
# Hide super user for no super user's (Pre-populating data)
   
def queryset(self, request):
       
if request.user.is_superuser:
           
return User.objects.all()
       
return User.objects.filter(is_superuser=False)


El miércoles, 9 de septiembre de 2015, 17:42:10 (UTC+2), Xavier Palacín Ayuso escribió:
I need hide a super admin's users from auth user model of Django of list users template for a normal users or no super admin users.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/779ae0a5-4315-4d19-9d26-fb92e53e0028%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment