S
S
sazhyk2018-11-12 13:12:26
Django
sazhyk, 2018-11-12 13:12:26

How to correctly compose the formset processing logic?

There is a form for creating an application on the site.

Site screenshot
5be942c963792768872958.png

I assume that there should be three models for the form. Please correct me if this is not how it should be:
models.py
from django.db import models


class BidDate:
    date = models.DateField()


class ChoiceList:
    choice_item = models.CharField()


class Bid:
    date = models.ForeignKey(BidDate)
    choice = models.ForeignKey(ChoiceList)
    note = models.CharField()

(Please do not poke at the wrong code, this is just a skeleton for understanding the essence of the issue)
The essence of the work is this. In the site admin panel, a list of options for selection is added (the "Option" column). The site initially displays the top circled plate on the screen. With the +/- (add/del) buttons, the user can add an option and a note to a specific date (lower plates). Using the "Add date" and "Remove date" buttons, the user can add and remove one more date, respectively (the second and third plates from the screen).
Actually the essence of the issue. Do I understand correctly that for such logic it is necessary to first create a formset for "Option and Note" in the forms.py file, and then create a formset for "Date and formset Option and Note"? Is it possible to do such nested formsets? And if so, in what order (well, purely algorithm) should I process them in views.py?
Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question