Lukas Humpe
Lukas Humpe

Reputation: 418

How to save model form Data(User input of multiple users) into the database or dict in Django

I am trying to set up a Website for Employee Scheduling with Django. I am new to Web development, therefore I run into some problems, scince I have the feeling the Web handles things differently. I need to pass information to a solver using pyomo.

For this employees should be able to pass information about their availability through a model form. The employee has to be able to submit his input by clicking in the shift button in the day row. When he is logged in.


e.g:

Day1 : [S1] [S2] [S3] [S4] [S5] [S6]

Day2 : [S1] [S2] [S3] [S4] [S5] [S6]

Day3 : [S1] [S2] [S3] [S4] [S5] [S6]

The data in the database should look like this

Employee               Shift      Day    Available

Username                S1         D1        0
Username                S2         D1        1
Username x              Si         Dk        0

For the solver the information has to be in a dict like this:

Available ={(“Username”, “S1”, “D1”): 0, (“Username”, “S2”, “D1”): 1, (“Username x”, “Si ”, “Dk”): 0}


0 means that the employee is not available on that shift on that day and 1 means he is. The x stands for the next user.

In this example the employee clicked on [S2] in the Day 1 row. So the model should automatically paste the day and the employee name. So I would have to be able to link the button to it’s related day and the model has to get the logged in user name.

Right now I get my data from a csv and transform it into a dict using pandas.

Is there any way to save the passed information as a csv or a dict into a database?

Upvotes: 0

Views: 283

Answers (1)

bhnir1
bhnir1

Reputation: 1

you can use Bulk Create and create a function that adds the data after reading it from the .csv file

Upvotes: 0

Related Questions