Some structure design is needed before we start the applications.
Django offers basic service as a framework should do, and all features or functions should be achieved by its applications.
First of all, we should know how the file structure looks like in a Django project. My folder structure is like this.
mysite/
mysite/
__init__.py
settings.py
urls.py
wsgi.py
app1/
__init__.py
admin.py
models.py
tests.py
urls.py
views.py
app2/
__init__.py
admin.py
models.py
tests.py
urls.py
views.py
static/
css/
img/
js/
media/
templates/
index.html
There are several important files inside a Django project, now we would know what role they are playing.
1.settings.py
2.urls.py
3.views.py
Django’s views are the information brokers of a Django application. A view sources data from your database (or an external data source or service) and delivers it to a template. For a web application the view delivers webpage content and templates, for a RESTful API this content could be properly formatted JSON data.
The view makes decisions on what data gets delivered to the template—either by acting on input from the user, or in response to other business logic and internal processes.
Each Django view performs a specific function and has an associated template.
4.models.py
5.admin.py
6.template
7.static
8.media