π₯ django-saas-boilerplate
A boilerplate to get started with Django, django-rest-framework on Heroku. It is great to start a API-first SaaS-application.
django-rest-boilerplate
βββ .circleci // CircleCI configuration
| βββ config.yml
βββ .github
| βββ ISSUE_TEMPLATE
| | βββ bug---problem.md // A Github template for reporting bugs
| | βββ feature_request.md // A Github template for posting new features
| βββ PULL_REQUEST_TEMPLATE.md // A Github template layout for Pull requests
βββ apps
| βββ core // Django core app
| βββ users // Django Users app
βββ conf // Django configuration folder
| βββ urls.py // The main url.py file
| βββ wsgi.py // The WSGI handler
| βββ settings // Django settings
| | βββ base.py // General settings
| | βββ local.py // Local settings
| | βββ production.py // Production settings
| | βββ test.py // Test settings
βββ devops // Devops + Infastructure
| βββ Docker // Docker container
| | βββ postgres // Postgres Docker
| | βββ redis // Redis Docker
βββ .coveragerc
βββ .env.example // Copy to .env for local development
βββ .gitignore // Default .gitignore
βββ .pre-commit-config.yaml
βββ .prospector.yaml
βββ LICENSE
βββ Pipfile // Pipenv file
βββ Pipfile.lock // Pipenv lock file
βββ Procfile // Declaration of Heroku processes
βββ README.md
βββ app.json // For automated Heroku deployment
βββ conftest.py
βββ docker-compose.yml // Docker handling for local development
βββ manage.py
βββ pytest.ini
βββ runtime.txt // Python version for Heroku deployment
βββ setup.cfg
βββ tasks.py
Read our documentation at ..
Download & install the Docker Community edition
Run the following commands, it will build & start the needed containers (Django, Worker, Postgres DB, Redis, Mailhog):
pipenv install --dev
docker-compose up -d
./manage.py migrate
./manage.py runserver
Open your browser and go to http://localhost:8000/
You can deploy project to Heroku using Deploy
button or Heroku instructions
https://devcenter.heroku.com/categories/working-with-django
Name | What is it? | Default |
---|---|---|
DATABASE_URL | Database's url | postgresql://${DB_USER}:${DB_PASSWORD}@localhost:${DOCKER_POSTGRES_PORT}/postgres for local, Heroku sets it automatically |
REDIS_URL | Redis's url | redis://redis:${DOCKER_REDIS_PORT} for local, Heroku sets it automatically |
ENV | App's environment | |
SECRET_KEY | Secret key that django requires for security | Heroku sets it automatically |
All other envs you can find in env.example
This project contains docker integration. You can run it with pipenv run go-docker
.
In any case before you need to write your .env
file with correct variables: when using the dockerized
local development setup, copy .env.local
; otherwise copy .env.example
to .env
, and modifiy
accordingly.
We are using prospectr + pre-commit to make things workable and clear. Before write any code you need to install
dev dependencies and run pre-commit install -f
after that. Then whenever you run git commit
you'll have a fancy
output with checks according to our code standards.
Work on new bug/features
will be done in a new branch (*)
There is a convention in the name of the branches used:
1-short-description-of-purpose
Naming a Branch:
#1 Initial Issue
> 1-initial-branch-name
Commits are the smallest portion of code that can be reviewed and has a purpose in the codebase. Each commit counts in a branch, not only the full set of changes.
Please follow this guideline: https://udacity.github.io/git-styleguide/
To use cool github linking to the issue please add #taskNumber in the end. E.g.:
docs: add changes to the Readme #123
Please make sure that each public class, method and function has meaningful documentation which describes the purpose of the code. To make things easier to follow we use Python annotations to the public functions and method. Cheat sheet: https://mypy.readthedocs.io/en/latest/cheat_sheet_py3.html
More info here: https://docs.python.org/3/library/typing.html