DEV Community

Connor Bode
Connor Bode

Posted on

What context gets passed to Django Admin template

So I'm modding Django Admin, like heavy.

It's fun. I really love the platform. You can bust out a dashboard, like lightning fast.

Anyways, enough chit-chat.

Let's say you're editing the change_form.html template. (you know, the one that lets you change an instance of a model), and you want to know what context variables get passed to that template.

If you're like me, you head over to Django's Github repo and grab the contents of the default change_form.html.

Then, you want to know what context gets passed down to the template. Here's what you do:

  1. Find a variable in the template. I just spotted is_popup.
  2. Use Github's search bar to find instances of is_popup in the Django repo:
  3. Notice that the first result has the word context kicking around.. probably a good bet.
  4. Click through to the result, and you'll see the full context for the view getting built

✌️ that's it for now, hope this tip will help you!

I can be found on Twitter @connorbode or at, where I write code.

Come say hi πŸ‘‹!

Discussion (0)