I’m trying to understand your question. If it’s about the organization you can
split your.py views into small modules if it gets too big.
original views.py follows below:
# (imports)
...
def view1(request):
pass
def view2(request):
pass
class IndexView(TemplateView):
template = 'core/index.html'
index = IndexView.as_view()
...
You can have that same structure in a more organized way.
Below is an example of how to modularize the same views.py.
views/
__init__.py
base.py
cbvs.py
base py. :
# (imports)
...
def view1(request):
pass
def view2(request):
pass
...
cbvs.py :
# (imports)
...
class IndexView(TemplateView):
template = 'core/index.html'
index = IndexView.as_view()
...
__init__py. :
from base import view1
from base import view2
from cbvs import index
In addition, you can use this same structure to organize other large files in your Django project.
I took a look here if there was no problem in doing the following: grouping all methods that return Httpresponse referring to my model into one class and make them static. I did it and it worked. Is there any problem in doing it from a technical point of view?
– juniorgarcia
Good question :)
– Wallace Maxters