Here I made an example of what I have in my admin.py:
@admin.register(Car)
class CarAdmin(CustomAdmin):
list_display = ('get_color',)
def get_color(self, obj):
return mark_safe('<a href="/admin/myapp/car/?color={}">{}</a>'.format(obj.color, obj.color))
I have produced a link that can be used to display cars with a specific color. Let's say the page is currently showing cars that cost less than $20k and I want this link to preserve the current filter. Any ideas how to do that? Maybe there is a way to get the current url from python.
Note that I know I can write a javascript to modify the links after the page is loaded, but that is a terrible solution.