blob: 2cd9152b62f690a54488250311038175b33d16fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# Django Base App
This is my Django starter base app. Nothing too fancy.
## What does it includes?
- Django
- Django REST Framework
- django-extensions
- Docker & docker-compose with a Postgres DB
- GitlabCI / Github Actions
- Linting with:
+ black
+ isort
+ flake8
+ pylint
+ mypy
+ pytest
- pre-commit configuration
- Makefile
- More?
## How do I use this?
Easy.
First, clone the repo:
``` sh
git clone git@gitlab.com:rogs/base_django.git --depth 1 <my_project_name>
cd <my_project_name>
```
Then, remove the Git folder, create a new git repo and add the remote:
``` sh
rm -rf .git
git init
git remote add origin <my_awesome_git_repo>
```
Finally, install the virtualenv:
``` sh
virtualenv .venv
source .venv/bin/activate
(.venv) pip install -r requirements.txt
```
## Available commands
The Makefile simplifies common development tasks for Django projects using Docker and Docker Compose. It provides shortcuts to build images, run migrations, start the development environment, and more.
### Base
- `build:`
Build Docker images using `docker-compose`.
- `makemigrations:`
Create new database migrations for your Django project.
- `migrate:`
Run database migrations to apply changes to the database schema.
- `createsu:`
Create a superuser for your Django application.
- `init:`
Combine `build` and `migrate` to set up the development environment.
### Development:
- `up:`
Start the development environment with `docker-compose`.
- `django-manage:`
A flexible target for running Django management commands. Use it like this:
make django-manage command=<Django_Command>
For example, to run `python manage.py test`, you would use:
make django-manage command=test
- `shell:`
Start a Django shell using `shell_plus`. This target provides an interactive Python environment for your project.
- `full:`
A combination of `init` and `up`. Useful for quickly setting up and starting the development environment.
- `kill:`
Stop and remove containers started with `docker-compose`.
- `cleanup:`
This target cleans up containers and removes associated volumes.
- `test:`
Use this target to run your Django tests. It accepts a `target` parameter to specify which tests to run.
make test target=<test_target>
Replace `<test_target>` with the specific tests you want to run.
- `bash:`
This target starts a Bash shell inside the Django app container, allowing you to access the container's shell.
|