Django is a back-end web framework written in Python.
It follows the model-template-view (MTV) architectural pattern.
The Model-Template-View Architecture
The Model-Template-View (MTV) architecture separates logically the definitions of a project in the following components:
- Model: defines data models
- View: defines how data is processed
- Template: defines how data is rendered and displayed
Django apps follows the MTV architecture.
Django Project Components
A Django project contains different Django apps that work together to provide the overall project functionality.
Django components in a project:
- Django project
- Django app(s)
- Database
- Virtual environment (optional)
Creating a Django project creates a project folder and also a file in the parent folder called “manage.py” that allows us to manage the Django project.
You may develop your Django project under a virtual environment, using venv
Python module. It may ease to deploy the project to a server.
A typical django working folder may contain the following folders or files:
db.sqllite3
(in case you used an SQLLite3 database)projectname_project
manage.py
(Python script to manage the Python project)appname_app
A Django project folder contains the following files as default:
__init__.py
asgi.py
settings.py
urls.py
: contains the URLs to be used in the projectwsgi.py
A Django app folder contains the following files as default:
- __init__.py
- admin.py
- apps.py
- migrations
- models.py
- tests.py
- views.py
Django apps follow the MVP. Templates are usually included in a templates folder.
The MTV Architecture in Django
Django Models
The Django Model Field Reference describe the kinds of fields that can be contained in a model. They can be checked on Django Templates
The Django templates can be checked on this external link. The workflow to process an URL can be described as follows: The Django shell is useful to check specific aspects of your Django project without having to browse through your applications. For example, you can use the Django shell to check the results of a query to your Django project database. The Django shell of a project is run by typing on a terminal:Django MTV Architecture Workflow
The Django Shell
python manage.py shell
You might also be interested in…
External references