Answer the question
In order to leave comments, you need to log in
What is the best CBV for my Django project?
Hello, I understand that the question sounds a little strange and is similar to the question from the women's forum: "What dress is better to wear to a party", but I will try to explain what made me ask such a question.
I'm creating a Django application that has a form, or rather several forms. First, one form is filled, depending on the value of one field of this form, using js, a formset appears, depending on the value of the formset field, another formset appears. The filled data is formed in an XML request and sent to remote servers, after which answers come and the data is written to the database, and a response is formed from the database and displayed on the page to the user.
For validation, sending and saving to the database, I used a function with a request parameter, for example:
def MyForm(request):
FirstFormSet = formset_factory(FirstForm, extra = 1, max_num = 15)
SecondFormSet = formset_factory(SecondForm, extra = 1, max_num = 20)
if request.method == 'POST':
first_form = FirstForm(request.POST, prefix='first_form')
first_formset = FirstFormSet(request.POST, prefix='second_form')
second_formset = SecondFormSet(request.POST, prefix='third_form')
if first_form.is_valid() and first_formset.is_valid() and second_formset.is_valid():
### cleared data ###
formdata.save()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question