Photo by Glenn Carstens-Peters on Unsplash

Simple modal to open details of an item (Django + bootstrap)

Antoine Garcia
2 min readApr 24, 2020

--

If you are using bootstrap + django (views & templates) and you happen to display a list of items that open a modal when clicking on it, here’s a simple implementation.

Let’s first show the list of incidents. For that we need a view and a template.

view.py
incident_list.html

Notice the “incident-modal.html” of the template above. Let’s add it then.

incident-modal.html

Now let’s add the view and template for what we’ll display in the modal.

By now, your urls should look like that:

And hopefully this approach answers what you were looking for.

NB: I don’t expect the gists above to fully work by simply copy-pasting them. I’ve just extracted the essential information from my code.

Please reach out if you think there’s something I can improve, (related to this article).

--

--