Hi Ken,
The main question here is if it is possible to have 2 fields at this posistion. I think not.
I use a MySQL external database. I solved the problem by creating a view there with a CONCAT_WS combining the 2 fields and give it a new name ādate_headerā
All you showed in your question was the rendering of a field within a for loop.
This isnāt a view, this is a model. This is the representation of where the data is stored. A view is the code that receives the request and renders and returns a response.
Cool! Yes, thatāll do what youāre looking to do.
However, Iād like to caution you against trying to inject too much logic into your templates. Thatās generally not the best way to do things in Django. Itās usually a lot better to build your data structures in your view, allowing the template to just render what is being presented to it.
Now, your site may be small enough that it doesnāt matter, but given enough users and weeks and shifts, you may find this approach to start to bog down. (Just something to keep in mind. If you start encountering response-time issues on this page, this would likely be one of the first items to evaluate.)
So there are a couple different ways to reduce the amount of logic in the templates.
The first, and probably the easiest that comes to mind is using the ifchanged tag to identify when a day or week changes.
The other would involve creating a couple of model methods, where each method is responsible for returning the set of rows for the next level down. For example, you might have a method to return all weeks, return all days for a week, and return all shifts for a day. Each level of the loop then iterates over each of those collections.
Either way, the mindset that you want to foster is that the work belongs in the view and models, not the templates. In Django, the templates are a second-class citizen.