You have to have the following tools installed prior initializing the project:
For easier running of everyday tasks, like:
- run dev server
- run all tests
- run linters
- run celery workers
- ...
We use invoke.
It provides shortcuts for most of the tasks, so it's like collection of bash scrips
or makefile or npm scripts
.
Also invoke
abstract "python interpreter", so you can use both virtual env
and
dockerized
python interpreter for working with project (see .invoke
file).
virtualenv
is the default approach that requires python interpreter, virtualenv, etc.dockerized
is simpler for quick starting project and for experienced developers
Suggested approach is using virtualenv
Project may use external services like Database (postgres), message broker,
cache (redis). For easier set up they are defined in docker-compose.yml
file,
and they are automatically prepared / started when using invoke
.
- Set up aliases for docker hosts in
/etc/hosts
:
127.0.0.1 postgres
127.0.0.1 redis
- Create separate python virtual environment if you are going to run it in local:
pyenv install 3.9.5
pyenv virtualenv 3.9.5 test_project-backend
pyenv local test_project-backend
pyenv activate test_project-backend
- Set up packages for using
invoke
pip install -r requirements/local_build.txt
- Start project initialization that will set up docker containers, python/system env:
inv project.init
- Run the project and go to
localhost:8000
page in browser to check whether it was started:
$ inv django.run
That's it. After these steps, the project will be successfully set up.
Once you run project.init
initially you can start web server with
inv django.run
command without executing project.init
call.
Open Pycharm settings
->Build,Execution,Deployment
->Console
->Django Console
then
copy below into Starting script
from django_extensions.management.shells import import_objects
from django.core.management.color import no_style
globals().update(
import_objects({"dont_load": [], "quiet_load": False}, no_style())
)
You will need:
Most of needed shortcuts can be called via invoke inv k8s.###
. Just make sure that you log in with
inv k8s.login
k8s.logs
k8s.python-shell