admin search_form needs request object

Hi,

This question is about a customization of the Django admin.

As I understand, change_list.html uses the search_form templatetag, which then renders the template search_form.html.

I want to customize search_form.html to provide some on-hover tips for users. I’ve done that (using a templatetag of my own to generate the tips) and it works fine.

Now I need to customize the tips based on some session data. Unfortunately, while many admin templates can simply access {{ request.session.blah }}, the search_form.html template is rendered with a restricted context (defined in the search_form function of admin_list.py).

The question is: what’s the (best) way to pass the request info I need down to the search form template?
I’ve tried wrapping the {% search_form cl %} expression in change_list.html with a new variable binding the session info I need, but the variable is not visible either.

Any clue is much appreciated!

Thanks

One obvious solution, which does work, consists of simply copy/pasting the content of search_form.html within change_list.html. A solution that would avoid this copy/paste would be better, though.

No specific ideas for sure, but just a couple of thoughts:

Could you bind the required data (tool-tip help) in the outer page and then just reference it from the tool-tip handler within the form?

(Is it possible to “re-register” the “search_form” tag to be your specific implementation instead of the system default?)