Views.py grows with time, there is a need to create a large function and I would like to create a separate file for it. How can this be better implemented and is it even possible?
2 answers
You can create a module with any name and place it anywhere. views.py is just a tacit agreement, junga itself does not prohibit.
If the application is complex, then the logic needs to be scattered across other files as it is done in normal projects, bringing to the view, for execution, only the high-level functionality.
In this form, all the functions of the views (if they are functions) will be small enough. With classes similarly.
Can. You can take out at least all the functionality in a separate module, and call, passing request to it and getting the finished page.
You can also bring vivas into separate files, then just in the urls file you’ll catch the request approximately like this: url (r '^ link / $', module_name_s_views.view_name, name = 'name'),