I had been worried about it for a long time, and I was trying to compare the people who handed it over to the template in the dictionary type, but it didn't work. I finally solved it.
The solution was solved by converting it to a string type and comparing it.
schedule.html
<tbody>
{% for staff in user_list %}
<tr align="center">
<th class="staff_name" staff_id="{{ staff.staff_id }}" width="200" >{{ staff.last_name }} {{ staff.first_name }}</th> <!--staff_id element used in js-->
{% for item in object_list %}
{% if item.user|stringformat:"s" == staff.username|stringformat:"s" %} ###Convert to string here
<td class="day_{{ item.date }}" id="s{{ staff.id }}d{{ item.date }}">
{{ item.shift_name_1 }}
</td>
{% endif %}
{% endfor %}
</tr>
{% endfor %}
</tbody>
Finally. I really had a hard time ... Even if I displayed it on the screen, it was displayed as atsushi, so I didn't understand it for a long time.
I doubt that it can be really compared, and if I compare it with item.user = "atsushi", it is judged that they do not match ... I found out that I didn't recognize it as a string here. It takes a few hours to get here ... (laughs)
Finally I was able to display the registered shifts!
This is the html that can display this.
schedule/month.py
{% extends 'schedule/base.html' %}
{% block header %}
{% endblock header %}
{% block content %}
<table class="table table-striped table-bordered">
<thead>
<tr align="center" class="info"> <!--date-->
<th rowspan="2"></th>
{% for item in calender_object %}
<th class="day_{{ item.date }}">{{ item.date | date:"d" }}</th>
{% endfor %}
<tr align="center" class="info"> <!--Day of the week-->
{% for item in youbi_object %}
<th class="day_{{ item.date }}">{{ item }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for staff in user_list %}
<tr align="center">
<th class="staff_name" staff_id="{{ staff.staff_id }}" width="200" >{{ staff.last_name }} {{ staff.first_name }}</th> <!--staff_id element used in js-->
{% for item in object_list %}
{% if item.user|stringformat:"s" == staff.username|stringformat:"s" %}
<td class="day_{{ item.date }}" id="s{{ staff.id }}d{{ item.date }}">
{% if item.shift_name_1 != None %}
{{ item.shift_name_1 }}
{% endif %}
{% if item.shift_name_2 != None %}
{{ item.shift_name_2 }}
{% endif %}
{% if item.shift_name_3 != None %}
{{ item.shift_name_3 }}
{% endif %}
{% if item.shift_name_4 != None %}
{{ item.shift_name_4 }}
{% endif %}
</td>
{% endif %}
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
{% endblock content %}
Next, I would like to add a process of coloring depending on the facility.
Finally willing to be happy: relaxed:
Recommended Posts