Skip to content

Requirements and Installation

Eray Erdin edited this page Mar 3, 2022 · 11 revisions

Requirements

In order to use SOS Django Template, you must have the dependencies below satisfied:

  • Python 3.7+
  • Django 3.2+ (pip install "django<4" and $HOME/.local/bin in your PATH variable)
  • Poetry

Why not Django 4?

Usually, every *.2 release is LTS in Django project and Django 4 does not have 4.2 yet. Also, 3.2 will be supported until April 2024.

This template is built under the environment below, so you better have same or similar environment in order to not fail on installing or in development phase:

  • Ubuntu 20.04: I personally use Ubuntu server to deploy my applications so Ubuntu is my choice.

Installation

Setting Up Project

This is usually how you create a plain Django project:

django-admin startproject PROJECT_NAME

This command also has an underutilized --template flag that can be used to get a template online, which should be a ZIP file. Then it extracts it to defined location, which is your project's name.

So you can create a SOS Django Template project by doing:

django-admin startproject PROJECT_NAME --template https://github.com/erayerdin/sos-django-template/archive/master.zip

master.zip is the master branch of this repository, which contains the latest released version of SOS Django Template. If you'd like to get a specific version, you can also do:

django-admin startproject yourProjectName --template https://github.com/erayerdin/sos-django-template/archive/refs/tags/<VERSION_HERE>.zip

Change <VERSION_NAME> with the version you'd like to have. You can check out Releases page to see the versions you can install.

Installing System Dependencies

cd into project root and do:

bash ubuntu20.requirements.bash

Changing Project Information

You should update pyproject.toml and LICENSE.txt files to your needs. Also, you must create .env file (renaming .env.example is the easiest way).

xdg-open pyproject.toml  # edit pyproject.toml file
xdg-open LICENSE.txt  # edit license info

mv .env.example .env  # rename .env.example to .env
xdg-open .env  # edit .env, put your db info etc.

Remember to change DJANGO_SECRET_KEY variable in .env file else it won't work.

Installing Project Dependencies

Inside project root, do:

poetry shell  # creates a new poetry environment
poetry install  # install prod and dev dependencies

If you are in the production environment, you can easily opt out of development dependencies by doing this:

poetry install --no-dev  # install only prod dependencies

Configuration

Pre-Commit

Before you install precommit, remember to git init.

pre-commit checks for a couple of things before you commit to your repository, such as if the code you commit is properly formatted or if the imports are properly sorted etc.

It is optional but a good practice to use pre-commit. To install it, do:

pre-commit install

At this point, you are ready to start development. Well done!