Calender

Im mostly doing this to learn, but I have a design in mind where there's a calender (like with almost any kind of scheduling tool). Im trying to figure out how to acutally set it up, my assumption would be that I need a hugh grid (green) https://i.imgur.com/lJAhMjN.png. The next issue is that I don't understand how to: 1. make each square different and have custom data. 2. change appearance such as red for special holidays etc. Im currently using Python/Django for the code and im using templates, even tho Im not 100% sure what that is, it seems like I can inser them. For example I have navbar.html, home.html. Would It make sense to have date.html for the squares, or would i need date1.html, date2.html.. etc. Usually there's a better way.
1 Reply
Jochem
Jochem17mo ago
I'd argue for presenting the calendar in a <table>. You're only supposed to use them for tabular data, not for presentation reasons, but I'm pretty sure a calendar is tabular in nature. As for templates, I'd stick with a single template for the entire calendar. You can abstract days away into a template if they get too complicated, but then I'd have a calendar template that includes a day template 28-31 times with different data. as for changing the appearance, you'll have to add a class to the element that represents the day making each square have different data is honestly too broad to answer without code. I don't remember how Django's templating works, but it will definitely be able to use variables, so very generally, you'd create a loop that runs once for each field in your calendar, and outputs a cell. You'd change what you pass to the day template, or just use the data for that day to output the information for that day and set the class for the color