A django project generated from: ninanor/django-template
Features:
- Docker
- REST APIs
- docker
First, if you are lazy execute
source helpers.sh # or . helpers.sh
This will create some shortcuts to run docker commands.
docker compose --profile dev up -d --build
# or dpli_dev up -d --build
This will build the docker images for local development and startup everything.
NOTE: the docker-compose.yml
uses bind-mounts, so editing your local django files will trigger a server reload without needing to rebuild the whole image.
In case you want to install new libraries (via apt-get
or pip
) ou will need to rebuild.
The development setup will by default create a administrator user ([email protected]) with password: admin. At every container start it will apply new migrations.
Django provides useful command line tools that can be executed with manage.py
, to see a list of all the available commands run inside the django container manage.py help
.
Check Django documentation for a list of the builtin commands.
Here are some examples of how to run them from your command line:
djcli_dev makemigrations # it will detect changes in your model files and will create SQL scripts to migrate tables accordingly
This is actually an alias for
docker compose --profile dev exec -it django-dev mange.py makemigrations
You can then review the migration script created and apply it with:
djcli_dev migrate
Other useful commands:
createsuperuser # creates a new administrator account
shell_plus # open an interactive python shell
showmigrations # shows a list of migrations, useful to know which ones are applyied
dumpdata # dump data from a table into a json file
loaddata # load data from a json file to a table
models2puml #
This setup will create docker images optimized for production, without devtools installed
docker compose --profile prod up -d --build
# or dpli_prod up -d --build
copier update --trust
This will try to check differences between your project and the template, if no conflicts are found you are done. Check this page for more specific info about this feature.