Question

I'm trying to access the user / request variables in django admin templates.

Specifically, I'd like to add new submit buttons depending on the user role. I've copied submit_line.html in my project template folder, but calling {{user}} or {{request}} don't display anything.

I've already added the following in my settings file.

TEMPLATE_CONTEXT_PROCESSORS = (
    "django.contrib.auth.context_processors.auth",  
    "django.core.context_processors.request",
)

Did I miss something?

Alternatively, is there a standard way to add submit buttons besides editing submit_line.html?

Was it helpful?

Solution

If you read the code for the submit_row templatetag (the one that renders submit_line.html), you'll notice that the original context is not passed to the submit_line.html template.

I'm afraid your best bet will be to replace the submit_row templatetag with something of your own, and override the admin/change_form.html template to call your own templatetag instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top