A template to quickly get up and coding your Django apps.
-
As a Django developer, while starting a new project, i find myself doing the same thing over and over again. That is, setting up a docker environment for development, installing django, running the
startproject
command and more. -
The goal of this
repo
is to instantly spin up a django environment for development, with the following as key factors- Consistency.
- Simplicity.
- Ease of use.
-
At this point, it is safe to say you are familiar with Python & Django.
Make sure to have docker and docker compose installed on your system, this will be needed as this project is designed to run in a docker environment. Please refer to Docker to get started with docker if you need to.
- Create a virtual environment:
python -m venv venv
- Clone the contents of this repo into your new project directory. Make sure to add the (.) period sign after the url.
git clone https://github.com/realestKMA/djangoup.git .
- Install dependencies in the
requirements
file usingpip
:pip install -r requirements.txt
- If you need to upgrade all packages in
requirements.txt
file do:pip-review --auto
- create an
.env
file with data from the.env.sample
and fill the required details:cp .env.sample .env
- Build the docker compose file using the dev yaml file:
docker compose -f docker-compose.dev.yml build
- Bring up the docker compose file and start coding:
docker compose -f docker-compose.dev.yml up
Your project is now up and ready for development, you can now access it by visiting http://127.0.0.1:8000. Changes made while you code will automatically reflect on the docker instance.
- Create a virtual environment:
Please note, the settings module has been split into three seperate modules as per my preferred use case inside the settings folder in the src project. These are
-
This module houses settings that span both development and production environment.
-
This module imports all settings from the
base
module. Here, i provide and/or make changes that is required for my development environment. -
This module also imports all settings from the
base
module. Here, i provide and/or make changes that is required for my production environment.
Environment variables are referenced in the src/env.py
module. This way, you can simply import the env
module and do
SECRET_KEY
= env.SECRET_KEY
To get up and coding your django apps, a postgres
database has also been provided in the docker compose file. This will serve as the default database as specifeid in the development.py & production.py settings module.
Few convenient bash
scripts are provided
This folder contains the docker files per service if explicitly required.
Make changes that suite your need. Thanks.