I’m working on a Django project where I need to include a delete confirmation modal in 10 different views (e.g., for deleting buildings, units, etc.). Each modal shares a similar structure but requires a unique warning message and action URL depending on the view.
I know I can simply copy and paste the modal code into each template, but I’m curious about the best design practices for handling this situation, especially when it comes to maintainability and clarity.
I’ve considered the following approaches:
- Using a Partial Template: Creating a reusable partial template for the modal and passing the dynamic content (URL, warning message) from the view.
- Defining the Modal in Each Template: Copying the modal structure into each template and customizing the content for each case.
- Using Template Inheritance: Defining a base modal template with blocks for the message and URL, which can be overridden in each child template.
I’m also aware that by abstracting some of the styling concerns into Tailwind components (like buttons and modals), I’ve separated some consistency concerns, but I’m still curious about the best approach from a design and maintainability perspective.
Given that the modal needs to be consistent across the app but with different content, what would be considered the best practice here? How do you balance reusability, clarity, and maintainability in such scenarios? Would love to hear your insights!