Django — Limit Queryset For ModelAdmin List View

This is documented:

To modify a query based on user, override the ‘queryset’ for ModelAdmin like so. Should give enough ideas:

	def queryset(self, request):
		qs = super(PanelTasting, self).queryset(request)
		if request.user.is_superuser:
			return qs
		return qs.filter(host__user=request.user)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s