Skip to content

Latest commit

 

History

History
104 lines (82 loc) · 1.68 KB

work_step.md

File metadata and controls

104 lines (82 loc) · 1.68 KB

Folder Structure

blogger


  • venv
  • manage.py
  • core
    • setting
      • base.py (base settings)
      • local.py
      • production.py
  • To run project
$ (venv) PS blogger>> manage.py runserver
  • Added condition to manage.py for DEBUG true or false condition

  • Secret key generate command

 $ .\manage.py shell
>>> from django.core.management.utils import get_random_secret_key
>>> print(get_random_secret_key())
>>> exit()
  • Install python-dotenv

  • Create .env within the project directory. File stracture

blogger

core > .env

and put the code

SECRET_KEY =SECRET_KEY

DEBUG = True
  • Add below line into the base.py file
from dotenv import load_dotenv
import os

SECRET_KEY = os.environ.get('SECRET_KEY')
DEBUG = os.environ.get('DEBUG') == 'True'
  • install pytest-django and create a file at root directory as name
pytest.ini
  • To run test use below command
pytest
  • Create a new app
 $ (venv) PS D:blogger> ./manage.py startapp blog
  • install pip pytest cov
pytest --cov
 pytest --cov-report html --cov=./
  • After configure Factory boy
(venv) PS D:\PROJECT\djblogger> py manage.py shell
>>> from blog.factory import PostFactory
>>> x = PostFactory.create_batch(200)
>>> exit()

render PostgreSQL setup

> set DATABASE_URL= internal or external database link