Лучший способ сгруппировать модели по двухнедельным периодам и привязать их к вводу данных?Python

Программы на Python
Гость
Лучший способ сгруппировать модели по двухнедельным периодам и привязать их к вводу данных?

Сообщение Гость »


Я работаю над проектом, рассчитанным на двухнедельный период. У меня есть модель с start_date и end_date, как показано ниже:

Код: Выделить всё

class CreateNewTimesheet(models.Model):
employee = models.ForeignKey(Employee, on_delete=models.CASCADE)
start_date = models.DateField(_("Start Date"))
end_date = models.DateField(_("End Date"))
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
Я хочу иметь возможность добавить еще одну строку или что-то еще, группирующее начальную_дату и конечную_дату.

Код: Выделить всё

Dates: 03/06/2024 - 03/16/2024

And group or tie that to "week 1".
The purpose behind this is to create a timesheet based on a two week time period. I need to be able to group the timesheets by a two week period and tie them to that specific group. All of the Timesheets need to be stored.
After start_date and end_date are entered I need them to be tied to week one. I was thinking about adding another line to the CreateNew model and then tie that to week one. And then each start_date and end_date are entered, a new "week" is entered for each new start_date and end_date is created. Should that be based off of created_at entry? Should each week be grouped by a new url?
I am honestly stuck at this point about both grouping by two weeks and then tying to a new week.


Источник: https://stackoverflow.com/questions/781 ... data-entry

Вернуться в «Python»