Skip to content

Commit d4b684e

Browse files
committed
Renamed and added some more make commands
Added: * sync * manage * makemessages * makemessages-all * compilemessages * collectstatic * update Renamed: * migrations -> makemigrations * Both to try and distinguish it more from `migrate`, and to make it have the same name as the actual management command, which can be useful (habit-wise) when running `makemigrations` in other contexts * superuser -> createsuperuser * For the same, latter reason as above * run -> start * "Run" was a bit ambiguous in that it could sound like you wanted to run some arbitrary command (like `uv run`). Also, if going by the same reasoning as the two points above, `runserver` would have been a bit long for such a frequently used command. Also removed `startapp`, as it's used so incredibly rarely that it's not very useful having it as its own `make` command. Also made `shell` use `shell_plus`, which is usually more useful.
1 parent 4835a81 commit d4b684e

File tree

3 files changed

+49
-15
lines changed

3 files changed

+49
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Lastly, a new [release](https://github.com/MAKENTNU/web/releases) must be create
3434
(MAKENTNU/web#766)
3535
- Replaced `local_settings.py` with `.env` (MAKENTNU/web#767)
3636
- Developers must create a `.env` file locally - see the "Setup" section of the README
37+
- Renamed and added some more `make` commands (MAKENTNU/web#768)
3738

3839

3940
## 2025-05-03 (MAKENTNU/web#757)

Makefile

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,41 @@
1-
run:
2-
uv run manage.py runserver 0.0.0.0:8000
1+
sync: ## Makes your locally installed packages match the ones specified in `pyproject.toml`.
2+
uv sync --group dev
33

4-
migrations:
5-
uv run manage.py makemigrations ${A}
4+
manage: ## Runs the Django management command specified by passing `args`.
5+
uv run $(uv_args) manage.py $(args)
66

7-
migrate:
8-
uv run manage.py migrate
7+
shell: ## Enters a Django shell, with most common classes automatically imported.
8+
make manage args="shell_plus"
99

10-
superuser:
11-
uv run manage.py createsuperuser
10+
migrate: ## Updates the database schema from the migration files.
11+
make manage args="migrate $(args)"
1212

13-
startapp:
14-
uv run manage.py startapp
13+
makemigrations: ## Creates migration files from the models, if there are any changes.
14+
make manage args="makemigrations $(args)"
1515

16-
shell:
17-
uv run manage.py shell
16+
makemessages: ## Extracts all translatable strings from the codebase and updates the `.po` files with them.
17+
make manage args="makemessages $(args)"
1818

19-
test:
20-
uv run manage.py test
19+
makemessages-all: ## Runs `makemessages` for all languages and domains.
20+
make makemessages args="-a"
21+
make makemessages args="-a -d djangojs"
22+
23+
compilemessages: ## Updates the `.mo` files from the `.po` files.
24+
make manage args="compilemessages $(args)"
25+
26+
collectstatic: ## "Compiles" the static files (CSS and JS files, images, etc.) into the `STATIC_ROOT` folder.
27+
make manage args="collectstatic --no-input"
28+
29+
update: ## Updates the installed packages, database and static files.
30+
make sync
31+
make migrate
32+
make collectstatic
33+
34+
createsuperuser: ## Creates a superuser.
35+
make manage args="createsuperuser"
36+
37+
start: ## Starts the Django webserver.
38+
make manage args="runserver $(args)"
39+
40+
test: ## Runs the test suite. Pass extra arguments with `args`, e.g. `args="-k 'test_function'"`.
41+
make manage args="test $(args)"

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@
2727
```
2828
1. Create an empty `.env` file directly inside the repository folder, and fill it by
2929
copying the contents of [`.env.example`](.env.example)
30+
1. To be able to run commands in the `Makefile`:
31+
* If using Windows:
32+
* Ensure that you have a program installed that can run makefiles.
33+
This can be done by e.g. installing
34+
[GnuWin's Make](https://gnuwin32.sourceforge.net/packages/make.htm) using
35+
[WinGet](https://learn.microsoft.com/en-us/windows/package-manager/winget/):
36+
```bash
37+
winget install GnuWin32.Make
38+
```
39+
* If using Linux/macOS: You don't need to do anything.
3040

3141
#### PyCharm
3242

@@ -71,6 +81,8 @@ When running uv commands, pass [the `--offline` flag](https://docs.astral.sh/uv/
7181
For example:
7282
```shell
7383
uv run --offline manage.py runserver
84+
# Using the make command:
85+
make start uv_args="--offline"
7486
```
7587
</details>
7688
@@ -89,4 +101,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for the following topics:
89101
## 📝 Changelog
90102
91103
[View the changelog](CHANGELOG.md) to see a list of changes made to the website over time,
92-
as well as a superficial description of the release process.
104+
as well as a high-level description of the release process.

0 commit comments

Comments
 (0)