====== Django: How To ======
===== Create Project Folder and Virtual Environment =====
Create project folder and navigate in it
md project_folder
cd project_folder
Create Virtual Environment
python -m venv .venv
Activate Virtual Environment (windows)
C:\path\to\project> .venv/Script/activate
Update ''pip'' in the Virtual Environment
(.venv) path/to/project> python -m pip install --upgrade pip
Install Django
(.venv) path/to/project> python -m pip install django
===== Creating a Project =====
Create the project with
(.venv) path/to/project> django-admin startproject
The project directory should look like this:
project_name/
manage.py
project_name/
__init__.py
settings.py
urls.py
wsgi.py
===== Creating an App =====
Create an app using
(.venv) path/to/project> python manage.py startapp
Inside the ''app_name'' folder create the file //''urls.py''//
cd app_name
touch urls.py
The project directory should now look like this:
project_name/
manage.py
db.sqlite3
project_name/
__init__.py
settings.py
urls.py
wsgi.py
asgi.py
app_name/
migrations/
__init__.py
__init__.py
admin.py
apps.py
models.py
tests.py
urls.py
views.py
To include this app in your project, add your app to the **''INSTALLED_APPS''** list in the ''settings.py'' file
INSTALLED_APPS = [
'app',
# ...
]
===== Views =====
===== Templates =====
===== Models =====
===== Model Objects e Queries =====
===== Registrazione Models per Admin Page =====
===== File Explanation =====
^Root^File Name^Description^
|project_name|settings.py| |
|project_name|urls.py| |
|project_name|wsgi.py| |
|project_name|asgi.py| |
===== Settings Explanation =====
===== Important Settings =====