Don’t understand some basics of CBVs. Would like to let my CreateView make some server-side checks on formfields before it redirects to another URL. Don’t know how to do it and would like to understand how I could have solved that by consulting the documentation.
Praise to the django documentation team
I’m new to django. At first I would like to make the whole django documentation team a huge compliment. It’s at least one of the best documentations I have read in the last years. So if anyone from the team is reading: Thanks so much!
Actually I’m struggleing a bit with Class Based Views. After reading the documentation  and and API reference  I (think I) got some basic understanding on what’s happening. The cool diagrams  from @bmtymrak also helped to get some understanding of the processes.
The actual issue
I’m using a CreateView to create a form which input data is stored in a model after submitting it. Before the data from the form is stored in my model, I would like to perform some more complex checks on a server-side. For now, let’s just assume that I would like to test if formfield_one (an int value) is bigger than formfield_two (also an int). If that is True, a redirect to the success URL shall take place. Otherwise an error message shall be raised.
What to do?
Having a look at the CreateView API reference  unluckily didn’t help me. Looking at the CreateView’s diagram  I noticed, that the FormView (the CreateView inherits) seems to be able to make some form.is_valid() checks, but I can’t find anything about that in the official documentation . So this seems to be a dead-end.
Looking at the UML diagram of the CreateView from another source , it shows me that the ModelFormMixin has a form_valid() function. In the ModelFormMixin documentation , I can see that there is a description for the form_valid method [==> “Saves the form instance, sets the current object for the view, and redirects to get_success_url()”]. But that’s the point where I don’t know what to do.
Is this the point where I should place some additional checks? If that’s the case: How?
And for me even more important: How could I have found the answer in the documentation by myself?
Thanks and regards,
 Class-based views | Django documentation | Django
 Built-in class-based views API | Django documentation | Django