View Code? Open in Web Editor
NEW
Learning the basics of django
Python 13.23%
HTML 6.08%
CSS 34.78%
JavaScript 45.92%
learn_django_basics's Introduction
Task |
Command |
Create virtual environment |
python3 -m venv venv |
Activate virtual environment |
source venv/bin/activate |
Deactivate virtual environment |
deactivate |
List installed packages |
pip list |
Create requirements.txt file |
pip freeze > requirements.txt |
Install packages from requirements.txt |
pip install -r requirements.txt |
. |
. |
. |
. |
Task |
Command |
Creating a new project |
django-admin startproject project_name |
Start a server |
python manage.py runserver |
. |
. |
. |
. |
Task |
Command |
Create a new app |
python manage.py startapp appName |
Consolidate static files |
python manage.py collectstatic |
Task |
Command |
Migrate the database |
python manage.py migrate |
Make migrations |
python manage.py makemigrations |
. |
. |
- Create the model (class) in models.py
- Add the app to the settings
- Create a migration
- Migrate
- Add the model to the admin
Task |
Command |
Create superuser |
python manage.py createsuperuser |
. |
. |
. |
. |
Task |
Command |
Start the service |
sudo service postgresql start |
Connect to postgres |
sudo -u postgres psql |
Check user accounts |
\du |
Create database |
CREATE DATABASE name; |
Check port number |
\conninfo |
Change user password |
\password username |
Delete Database |
DROP DATABASE db_name |
Quit psql |
\q |
Show databases |
\l |
. |
. |
. |
. |