Local
Getting it to run and look nice
- Configure initial settings to run on local machine
- Integrate local database, see example with postgres
- Running Tailwind build step when adjusting UI
- Using social auth callback urls with
127.0.0.1
as the host
Setting up tests
Creation
- I'll often do docstring tests to quickly unit test a function so I can grok it immediately.
- If this requires a formal
*.test
file, I'll populate the/src/tests
folder
Running
Instead of having to write the full options list, can simply run pytest
on the shell
and it will adopt the configuration declared in pyproject.toml :
pyproject.toml x pytest
pyproject.toml
[tool.pytest.ini_options]
minversion = "7.0"
pythonpath = "src" # (1)
addopts = "-ra -q --ds=config.settings --doctest-modules --cov" # (2)
filterwarnings = [
"ignore::DeprecationWarning", # (3)
"ignore::django.utils.deprecation.RemovedInDjango51Warning" # (4)
]
testpaths = ["tests"]
- is at
src
so it's as if pytest is running under this context - Note
--ds=config.settings
refers to the use of pytest-django - Ignore the noise- DeprecationWarning: pkg_resources is deprecated as an API
- Ignore the noise- GET_STORAGE_CLASS_DEPRECATED_MSG
Configuring shortcuts
just start
Requires: npm
, poetry
, just
Bash
# (1) setup
cp ./etc/env.example.0.dev-op .env
poetry install
poetry shell
npm install -D tailwindcss \
@tailwindcss/typography \
@tailwindcss/forms \
@tailwindcss/aspect-ratio \
@tailwindcss/container-queries
npx tailwindcss -i ./src/static/css/input.css -o ./src/static/css/output.css
# (2) just req
poetry export -f requirements.txt \
--without-hashes \
--output src/requirements.txt
# (3) just press
rm -rf ./src/static/CACHE
cd src && python manage.py collectstatic --noinput
cd src && python manage.py compress --force
# (4) just db
cd src && python manage.py makemigrations
cd src && python manage.py migrate
# (5) test then run
pre-commit autoupdate
cd src && pytest
cd src && python manage.py runserver_plus
- Setup .venv, create an .env file model and place it in the root
- Adds a
requirements.txt
inside/src
based onpyproject.toml
dependencies. - Runs collection and compression of staticfiles.
- Populates database for use based on existing models declared in
/pages
and/profiles
- Prep dev environment, sanity check on default boilerplate
just tw
npx tailwindcss -i ./src/static/css/input.css -o ./src/static/css/output.css --watch
just dumpenv
Requires: 1password
op inject -i ./etc/env.example.0.dev-op -o .env
just run
open -a "Brave Browser.app" http://127.0.0.1:8000/ && cd src && python manage.py runserver_plus
just work
cd src && python manage.py run_huey
Documentation
Explaining functions created in the documentation