I just started using django for development. At the moment, I have the following issue: I have to write a page template able to represent different categories of data. For example, suppose I have a medical record of a patient. The represented information about this patient are, for example:
- name, surname and similar data
- data about current treatments
- ..and beyond: specific data about any other analysis (eg. TAC, NMR, heart, blood, whatever)
Suppose that for each entry at point 3, I need to present a specific section.
The template for this page would probably look like a long series of if
statements, one for each data entry, which will be used only if that information is present. This would result in a very long template.
One possible solution is to use the include
directive in the template, and then fragment the main template so that instead of a list of if
's i have a list of includes, one for each if
.
Just out of curiosity, I was wondering if someone know an alternative strategy for this kind of pattern, either at the template level or at the view level.