Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Thorgate's Django template

Build status

Django project template that we use at Thorgate.

Best suited for medium-sized and bigger apps that use JavaScript and React for frontend or single page web applications.

(note that the primary repo is in Gitlab, with mirror in Github)

Features

  • Django-based backend

    • Django
    • Separate settings for different environments (local/staging/production)
    • Python 3.6 or later
    • [SPA] Accessible from port 3000 for local development
  • Frontend app with JavaScript (ES2015), React and Sass

    • Latest JavaScript features from ES2015 and beyond, transpiled with Babel
    • React for fast modular user interfaces
    • Sass, PostCSS and Autoprefixer for more convenient styling
    • Webpack is used to bundle and minify JavaScript and styles
    • [SPA] Accessible from port 8000 for local development
  • Batteries

    • Docker / Docker Compose integration
    • Linting of Python, JavaScript and Sass code with Prospector, ESLint and stylelint
    • Automated code-formatting using black and prettier
    • py.test and coverage integration
    • Deploy helpers, using Fabric
    • Media files are stored in a CDN like S3 or Google Cloud Storage
    • Out-of-the-box configuration for nginx, gunicorn and logrotate
    • Includes PyCharm project config

Usage

To use this template, first ensure that you have Pipenv 2020.6.2 available.

After that, you should:

  1. Install the requirements of the project template by running

    pipenv install
    
  2. Activate the virtualenv created by pipenv:

    pipenv shell
    
  3. Navigate to the directory where you'd like to create your project:

    cd /home/my-awesome-projects/
    
  4. Create a new project by executing:

    cookiecutter dir/to/django-project-template/
    

It will ask you a few questions, e.g. project's name.

After generation completes, you should deactivate virtual environment for cookiecutter, search for any TODOs in the code and make appropriate changes where needed.

See README.md in the generated project for instructions on how to set up your development environment.

Upgrading project template

First ensure you have a python3 interpreter with cookiecutter installed.

To upgrade an existing project, change the current working directory to the root of the project you want to upgrade. i.e. cd project-to-upgrade. Ensure your are not in the template branch.

Then run python ~/path/to/django-project-template/upgrade-template.py

This will make a commit to the branch template in your project with the updates to the project template. Then merge the template branch.

Docker images

The template uses our own images for CI runs. One for the template itself and a second one for generated projects. Both images are alpine based and contain python3, pip and some support packages. The images are published to repository container registry and also to docker hub.

The images are built in CI (from default branches only) and also updated every day via schedules.

Project CI Image

  • Dockerfile-ci
  • Image in repository registry: registry.gitlab.com/thorgate-public/django-project-template/ci
  • Image in docker hub: thorgate/django-template-ci

Template CI Image:

  • Dockerfile-base-ci
  • Image in repository registry: registry.gitlab.com/thorgate-public/django-project-template/base-ci
  • Image in docker hub: thorgate/django-template-base-ci
You can’t perform that action at this time.