Skip to content

Instantly share code, notes, and snippets.

@guillaumepiot
Forked from anonymous/gist:5056609
Created February 28, 2013 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guillaumepiot/5056613 to your computer and use it in GitHub Desktop.
Save guillaumepiot/5056613 to your computer and use it in GitHub Desktop.
class MyAdmin(admin.ModelAdmin):
list_filter = ['market']
# Duplicate list_filter to assign on a pre request basis
_list_filter = list_filter
# Change list filter on the view depending on user
def changelist_view(self, request, extra_context=None):
if not request.user.is_superuser:
self.list_filter = None
else:
self.list_filter = self._list_filter
return super(MyAdmin, self).changelist_view(request, extra_context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment