Skip to content

Latest commit

 

History

History
105 lines (82 loc) · 2.3 KB

README.md

File metadata and controls

105 lines (82 loc) · 2.3 KB

Screenshots attached on the very bottom

Purpose of this project was to
learn basic Django 3.2.9, MVT, ORM
DjangoDebugToolbar, Authorization, STMP
HTML, CSS, Jinja2

06.2021 @dianaGera


Build the project:


Setup

The first thing to do is to clone the repository:

$ git clone https://github.com/dianaGera/django-cheat-sheets.git
$ cd django-cheat-sheets

Create and activate virtual environment:

$ python3 -m venv venv
$ venv\Scripts\activate (Windows)
$ source venv/bin/activate (Linux)

Install dependensies for backend:

pip install -r requirements.txt

Restore the database using raw SQL

Create the PostgreSQL database

Set up PostgreSQL on Windows/Mac/Linux

Create Database (PostgreSQl official Documentation)

# Create the DB using default credentials or change it in settings.py:
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': os.getenv('NAME', 'django_lessons'),
        'USER': os.getenv('USER', 'django'),
        'PASSWORD': os.getenv('PASSWORD', 'password'),
        'HOST': os.getenv('HOST', 'localhost'),
        'PORT': os.getenv('PORT', '5432'),
    }
}

Restore the database

$ psql -h host -p port -d dbname -U username -f filename.sql

Path to db -> django-cheat-sheets/database/db.sql

Run migrations

$ python manage.py makemigrations
$ python manage.py migrate

Run Django server:

$ python manage.py runserver

** Enjoy :)


DATABASE:

dump the database into an SQL file

$ pg_dump -U username dbname > filename.sql
(Heroku CLI)$ heroku run --app you-app-name pg_dump -U username dbname > filename.sql

restore the database using SQL file

$ psql -h host -p port -d dbname -U username -f filename.sql
(Heroku CLI)$ heroku pg: psql -h host -p port -d dbname -U username -f filename.sql


Result


Screenshot



Screenshot