Friday, May 6, 2016

multiple INSERT with django form

Hi

I'm trying to create a django form based on the model. The model contains fields: username, date, shift, department, team. Team and Department are defined in different app and are extending the user through UserProfile. I would like to have a table that is generated automatically based on the number of days in the month and users from department and look more less like that:

xxxxx | Day1   | Day2   | Day3   | ... | Day31   |
--------------------------------------------------
User1 | Shift1 | Shift2 | Shift3 | ... | Shift31 |
--------------------------------------------------
User2 | Shift1 | Shift2 | Shift3 | ... | Shift31 |
--------------------------------------------------
User3 | Shift1 | Shift2 | Shift3 | ... | Shift31 |

where user (is a private key of another table) and day values will be added during the generation of the table and shift will be the dropdown box.

INSERT to the database should be constructed for each day (user1, day1, shift1, department, team) where department and team should be taken automatically based on the username from UserProfile.

I do not know where to start. I've looked at django formset and it would seem a way to go but the formset is generating a HTML table code and all fields are from the form would be in the table. Additionally I would like the possibility to change the generated table within the same view.

I would be very grateful if you can point me to the documents that might help me.

Cheers,
Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/acc6cbf4-9484-4dc7-a1ac-bd9b205d651b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment