[PYTHON] Add functionality to modify Django day shift information

In order to implement the function to edit while checking the shift table, I would like to be able to correct the shift of the day by clicking the working hours of each day.

First of all, I will create an update screen.

I created it using the easy-to-create UpdateView ...

schedule/views.py


class ScheduleUpdate(UpdateView):
    template_name = 'schedule/update.html'
    model = Schedule
    fields = ('user', 'date', 'shift_name_1', 'shisetsu_name_1', 'shift_name_2', 'shisetsu_name_2', 'shift_name_3', 'shisetsu_name_3','shift_name_4', 'shisetsu_name_4', 'day_total_worktime')
    success_url = reverse_lazy('schedule:homeschedule')

html/schedule.py


{% extends 'schedule/base.html' %}

{% block header %}
{% endblock header %}

{% block content %}
<form action="" method="POST">{% csrf_token %}
    <P >Employee name: {{ from.object.user }}</P>
    <p>date: {{ form.date }}</p>
    <p>Shift 1:{{ form.shift_name_1 }}</p> 
    <p>Facility name 1:{{ form.shisetsu_name_1 }}</p>  
    <p>Shift 2:{{ form.shift_name_2 }}</p> 
    <p>Facility name 2:{{ form.shisetsu_name_2 }}</p>  
    <p>Shift 3:{{ form.shift_name_3 }}</p> 
    <p>Facility name 3:{{ form.shisetsu_name_3 }}</p>  
    <p>Shift 4:{{ form.shift_name_4 }}</p> 
    <p>Facility name 4:{{ form.shisetsu_name_4 }}</p>
    <p>Total working hours:{{ form.day_total_worktime }}</p>
    <input class="btn btn-primary" type="submit" value="update">
    <a href="{% url 'schedule:homeschedule' %}" class="btn-secondary   btn active">Return</a>
</form>
{% endblock content %}

I made it this way, but I had a problem ...

I displayed the user name and date as information on the edit screen, but I don't want to edit them ... At times, I don't know how to do it ... What is hard here ...

After this, I felt that it would be difficult to create a function to acquire and display the time from the shift name. I stumbled before that ...

Click here for the current screen

image.png

I want to list the name and name instead of the user name, but I may have to hand it over again in a dictionary type, but I do not know how to hand it over ...

How many hours will I fight from here ... (laughs)

Recommended Posts

Add functionality to modify Django day shift information
Output user information etc. to Django log
Dynamically add fields to Form objects in Django
Try using django-import-export to add csv data to django
How to implement Rails helper-like functionality in Django
Display the Django shift table! Supports 20-day closing
[Python] [Django] How to use ChoiceField and how to add options
Add information to the bottom of the figure with Matplotlib