Is it possible and if so can someone point me in the right direction for this. Here is my model.py:
class Client(models.Model):
user_name = models.CharField
class Task(models.Model):
client = models.ForeignKey(
'Client',
)
task_type = models.ForeginKey(
'Task_Type',
)
date = models.DateTimeField()
class Task_Type(models.Model):
name = models.CharField
class Task_Value(models.Model):
value_num = models.DecimalField
task = models.ForeignKey(
'Task',
)
What I want to do is have a form that the user sees as:
- Task Type – Date (applied to all the following records)
- Client ID 1 – Task Value 1
- Client ID 2 – Task Value 2
- Client ID 3 – Task Value 3
- Client ID 4 – Task Value 4
Where a unique task record is created for every row that has valid values for client id, task type, and date. And a second record is created (in Task_Value table) for every valid task value and a foreign key link the the task_type event created in the same row.
Is this possible from one page/table or do I need to do some type of a quick en masse entry for the task type and then load a form as a table with he events just created and record the values separately? (This is for user entry, not admin entry)
So it would be something like formsets with a userdefined kwargs for the number of extras, but that share some common fields at the top that are not copied multiple times (so the user can create many records for the same date and task type). Each of the two formsets would only have one repeated field (Client ID for the task record and the task_value for the task_value record.). Then the second takes the pk from the first for the foreign key.
What you are looking for is Inline Formsets.
https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/#inline-formsets