I have a form called shift
here my forms.py
class ShiftForm(forms.ModelForm):
class Meta:
model = Shift
fields = '__all__'
and have createview class for my shift
here my views.py
class ShiftCreateView(CreateView):
fields = ('start', 'end', 'off_start', 'off_end', 'shift', 'employee')
model = models.Shift
and I already create the form template, like this.
its work and the data was submitted to my database, imagine my database table like this:
#table shift
+---------------+---------------+---------------+---------------+------------+------------+-------------+
| start | end | off_start | off_end | time | user_id | shift_id |
+---------------+---------------+---------------+---------------+------------+------------+-------------+
| 2018-01-01 | 2018-01-05 | 2018-01-06 | 2018-01-07 | 07:00 | 1 | 1 |
| .... | .... | .... | .... | .... | .... | ... |
+---------------+---------------+---------------+---------------+------------+------------+-------------+
my question is how to make it multiple in one form?...
example like this:
so on my database table will look like this in single submit.
#table shift
+---------------+---------------+---------------+---------------+------------+------------+-------------+
| start | end | off_start | off_end | time | user_id | shift_id |
+---------------+---------------+---------------+---------------+------------+------------+-------------+
| 2018-01-01 | 2018-01-05 | 2018-01-06 | 2018-01-07 | 07:00 | 1 | 1 |
| 2018-01-01 | 2018-01-05 | 2018-01-06 | 2018-01-07 | 07:00 | 1 | 2 |
| 2018-01-01 | 2018-01-05 | 2018-01-06 | 2018-01-07 | 07:00 | 1 | 3 |
| 2018-01-01 | 2018-01-05 | 2018-01-06 | 2018-01-07 | 07:00 | 1 | 4 |
| .... | .... | .... | .... | .... | .... | ... |
+---------------+---------------+---------------+---------------+------------+------------+-------------+
on my example above its 4 times submitted in one execute.
thank you!


RollingShift?FormSet) for this.FormSet?