Looks like the question is still unanswered and similar to another question. meesterguyperson posted there a great answer, go check it out.
The solution is to create a "fake filter" that will register a URL parameter with django but will not affect the queryset and admin site appearance.
I adapted meesterguyperson's answer a bit myself and instead of using a blank template to hide the "fake filter", I simply exclude it from the filter pane by returning False from has_output method.
from django.contrib.admin.filters import SimpleListFilter
class KwargPassThroughFilter(SimpleListFilter):
title = ''
# hide from filter pane
def has_output(self):
return False
# these two function below must be implemented for SimpleListFilter to work
# (any implementation that doesn't affect queryset is fine)
def lookups(self, request, model_admin):
return (request.GET.get(self.parameter_name), ''),
def queryset(self, request, queryset):
return queryset
Now, you can subclass this filter and override the parameter_name with the desired name of your param, e.g.
class NameKwargPassThroughFilter(KwargPassThroughFilter):
parameter_name = 'name'
and append register the filter in the ModelAdmin subclass
class SomethingAdmin(admin.ModelAdmin):
...
list_filter = (
...,
NameKwargPassThroughFilter,
...,
)
...
At this point, you can freely use the param in the URL and access it within the scope of SomethingAdmin pages...
Works for Django 3.0+