A
A
Alexey2016-01-05 00:43:17
Django
Alexey, 2016-01-05 00:43:17

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()

But the received data needs to be sorted, checked for duplicates and then displayed on the page. And here I am already confused how to implement it. I will also add that this form will be on the main page and in addition to the form there will be an apish with news, our latest products, and so on. Please tell me which CBV is better to implement all of the above, if at all it is implemented using classes. Thanks in advance for your reply.

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