I have a staff list. I have a model for this as follows.
models.py:
class NumberOfMealsEaten(models.Model):
month = models.ForeignKey(Months, on_delete=models.CASCADE)
staff = models.ForeignKey(Staffs, on_delete=models.CASCADE)
maelseaten = models.IntegerField("Number of meals eaten", validators=[MinValueValidator(0)], default=0)
def __str__(self):
return str(self.staff)
For these employees, the meal fee is calculated every month according to how many meals each staff has eaten.
First, at the beginning, I want to choose "the name of the relevant month" only once. Then I want the staff names from Foreignkey to be automatically listed as "text" in the template, not in the form of a drop-down menu. So I just want the "maelseaten" field filled in for the staff.
As an example, the list will look like this:
In other words, this form will add the number of meals for each staff member for the selected month to the database.
Thank you in advance for your attention and help.