An open API service indexing awesome lists of open source software.

https://github.com/emilte/django-workshop

Workshop for Django
https://github.com/emilte/django-workshop

django docker docker-compose python workshop

Last synced: 5 months ago
JSON representation

Workshop for Django

Awesome Lists containing this project

README

        

# django-workshop

Hi, and welcome to my workshop! 😊

In this workshop, you will learn the basics of Django, and lots of other treats the python environment can provide.

Before we can start though, I need you to do something for me. You see, there are some tools I cannot install for you 😔 Please take a look at the list in [prerequisites](#prerequisites) and install the required tools 🔧
The project was made primarily to run in docker, but is compatible with local setup aswell.






## Table of contents:

- [Table of contents:](#table-of-contents)
- [Prerequisites](#prerequisites)
- [Setup](#setup)
- [Step 1: Clone project](#step-1-clone-project)
- [Step 2: Copy environment files](#step-2-copy-environment-files)
- [Step 3: Run project](#step-3-run-project)
- [Step 4: Install dependencies (optional)](#step-4-install-dependencies-optional)
- [Step 5: Select interpreter in VSCode](#step-5-select-interpreter-in-vscode)
- [Documentation](#documentation)






## Prerequisites

See [prerequisites](/documentation/prerequisites.md).




## Setup

### Step 1: Clone project

Locate directory you want to have the project, clone the project and navigate into it.

```
git clone [email protected]:emilte/django-workshop.git && cd django-workshop
```




### Step 2: Copy environment files

These files configure the environment the code runs in.
After running these commands, I recommend taking a look at them.

> - [.vscode/settings.json](.vscode/settings.json) contains configurations for VSCode.
> - [clean/.docker.env](clean/.docker.env) contains environment variables/secrets for your container named `clean`.
> - [solution/.docker.env](solution/.docker.env) contains environment variables/secrets for the `solution` container.

```
cp .vscode/settings.default.json .vscode/settings.json
cp clean/.docker.example.env clean/.docker.env
cp solution/.docker.example.env solution/.docker.env
```




### Step 3: Run project

The workshop is setup with two docker containers I will reference throughout the workshop. One named `clean` and another named `solution`.

- The `clean` container is for the moment completely empty. This is where you will start your django project.
- The `solution` container is fully spec'ed with most of the tools I like to use on my own projects. It serves as an inspiration during your tasks as well as giving you an instant feeling as to what Django can provide.

> This command is expected to display errors for the `clean` container.
> There isn't a project inside it yet, but you will make one pretty soon 😉

```
docker compose up
```

The `solution` server is now running on [http://localhost:8002](http://localhost:8002).
You may browse the [admin panel](http://localhost:8002/admin).
Credentials can be found in [solution/.docker.env](/solution/.docker.env)




### Step 4: Install dependencies (optional)

This step is only to enhance the VSCode experience where it can recognise Django, enable formatter, linters etc.

```
cd solution
```

> `pipenv` will recognise dependencies automatically from [Pipfile](/solution/Pipfile).
> `PIPENV_VENV_IN_PROJECT=1` will ensure that the environment is installed within this folder.

```
PIPENV_VENV_IN_PROJECT=1 pyenv exec pipenv install --dev --python 3.11
```




### Step 5: Select interpreter in VSCode

`Cmd + Shift + P` --> `Select interpreter` --> `+ Enter interpreter path`

Write `solution/.venv` and hit `Enter`.






## Documentation

Go to [documentation](/documentation/README.md) to continue with workshop.