On Nov 20, 3:26 pm, JHeasly <jhea...@earthlink.net> wrote: > In using Simon W.'s "simple example of row-level permissions in the > admin" (http://www.djangosnippets.org/snippets/1054/), I'm trying to > extend the concept by modifying the 'list_filter' tuple of the > subclassed ModelAdmin based upon the request.user.is_superuser > property buy am struggling with how to hook it into my class. > > Intuitively, it seems like overriding the __init__ ModelAdmin is where > it needs to go. I've tried something like: > > def __init__(self, model, admin_site, request, *args, **kwargs): > if request: > if request.user.is_superuser: > self.list_filter = ('has_run',) > super(Death_noticeAdmin, self).__init__(model, admin_site, > request, *args, **kwargs) > > but the above fouls the registering of the Death_noticeAdmin class: > > File "/usr/local/lib/python2.5/site-packages/django/contrib/admin/ > sites.py", line 93, in register > self._registry[model] = admin_class(model, self) > > TypeError: __init__() takes at least 4 arguments (3 given) > > My lack of a completely thorough understanding of 'super' probably > isn't helping either. Any suggestions, ideas appreciated. > > — J.
Basically you don't want to pass the 'request' argument up the super class, as it isn't expecting it. Use the **kwargs magic instead. def __init__(self, model, admin_site, *args, **kwargs): request = kwargs.pop('request', None) if request: if request.user.is_superuser: self.list_filter = ('has_run',) super(Death_noticeAdmin, self).__init__(model, admin_site, *args, **kwargs) -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=.