Update settings.py, .env, .gitignore, pre-commit
- in the root folder (same level as manage.py) create file .env for storing passwords, logins, etc
SECRET_KEY=$fm-9j$4h@smnqh-d$*3
GITHUB_API_KEY=$fm-9j$4h@smx743eqh-d$*3
ALLOWED_HOSTS='["127.0.0.1"]'
- in settings.py and all files always get secret variables from .env
import os
import json
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ.get("SECRET_KEY")
ALLOWED_HOSTS = json.loads(os.environ['ALLOWED_HOSTS'])
- in the root folder create also file .gitignore and put all files you do not want to share on Github (.env, database, text editor setup, etc)
# misc
.DS_Store
.env
- PRE-COMMIT ( https://pre-commit.com/ )
pipenv install pre-commit --dev && pipenv shell && pre-commit --version
- create .pre-commit-config.yaml file in the root folder (same level as pipfile, .env ...)
pipenv pre-commit install
and after each commit all the files will be controlled and corected, so you have to add them and commit them again
repos:
- repo: https://github.com/ambv/black
rev: 20.8b1
hooks:
- id: black
- repo: https://github.com/prettier/pre-commit
rev: v2.1.2
hooks:
- id: prettier
entry: prettier --write --single-quote --trailing-comma=all
files: "\\.(\
css|less|scss\
|graphql|gql\
|js|jsx\
|json\
|md|markdown|mdown|mkdn\
|mdx\
|ts|tsx\
|yaml|yml\
)$"
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: debug-statements
- repo: https://github.com/hadialqattan/pycln
rev: v0.0.1-beta.0 # Possible releases: https://github.com/hadialqattan/pycln/tags
hooks:
- id: pycln
Resources:
➡️https://codeburst.io/tool-your-django-project-pre-commit-hooks-e1799d84551f