While tinkering with Wagtail (and inherently, Django), I found myself in no time with a very large views.py
file due to how Django sets up its endpoint management. For this reason, I decided I would attempt at segregating the responsibility of views.py
into separate files/classes, in order to make it easier to maintain and read.
The idea is close to an MVC pattern. Ideally there will be a Controller
that will implement the Action
(endpoint) logic, which will parse the request, its data, and will implement the necessary logic for the data lookup part. The result of this will be converted into a ViewModel
(Data class) which will be passed to a View
(Django template), ideally binding them together.
I have decided to implement a ControllerBase
(see below), that will be inherited by the rest of the Controllers in the solution.
All redundant logic, as well as the necessary methods needed in order to support Django's decorators, will be implemented and