Answer the question
In order to leave comments, you need to log in
Python / Django - how to organize the architecture?
Good afternoon.
After a little experience with PHP / Yii, my eyes fell on Django.
And immediately there were several questions about the architecture of the application.
In django, a controller means a view. By default, all controller actions are described in /views.py.
Task: write a site with a dozen different pages, each page has its own controller.
What is the best way to organize?
Do for each page (/home, /posts, /about) for the application? Those. organize as
--mysyte
----home
----posts
----about
----manage.py
?
Or do everything in one application and instead of one file views.py make a directory with controller files (where each controller is in a separate file)?
Answer the question
In order to leave comments, you need to log in
In general, you can do everything in one views.py and it will be correct, but if you are very impatient in different ones, then you can make a views folder and put everything there.
mysite/
manage.py
mysite/
__init__.py
settings.py
urls.py
wsgi.py
mysiteapp/
__init__.py
views/
__init__.py
home.py
about.py
contact.py
admin.py
models.py
tests.py
urls.py
daddy views and for each controller its own file, so I do. In general, as nobodynoone wrote. Only for simple controllers (contact, about) you can send default.py
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question