2024-07-14 21:14:07 +00:00
# data.coop member system
2019-08-31 22:25:25 +00:00
2024-07-14 21:14:07 +00:00
## Development setup
2023-10-02 18:10:24 +00:00
2024-12-25 23:03:26 +00:00
There are two ways to set up the development environment.
2023-10-02 18:10:24 +00:00
2024-07-14 21:14:07 +00:00
- Using the Docker Compose setup provided in this repository.
2024-12-25 23:03:26 +00:00
- Using [uv ](https://docs.astral.sh/uv/ ) in your host OS.
2023-10-02 18:10:24 +00:00
2024-07-14 21:14:07 +00:00
### Using Docker Compose
2024-12-25 23:03:26 +00:00
Working with the Docker Compose setup is made easy with the `Justfile` provided in the repository.
2023-10-02 18:10:24 +00:00
#### Requirements
2019-08-31 22:25:25 +00:00
2021-02-28 23:15:01 +00:00
- Docker
2024-07-14 21:14:07 +00:00
- docker compose plugin
2024-12-25 23:03:26 +00:00
- Just CLI (https://github.com/casey/just?tab=readme-ov-file#packages)
2019-08-31 22:25:25 +00:00
2023-10-02 18:10:24 +00:00
#### Setup
2019-08-31 22:25:25 +00:00
2024-07-14 21:14:07 +00:00
1. Setup .env file
2019-08-31 22:25:25 +00:00
2024-07-31 22:49:46 +00:00
An example .env file is provided in the repository. You can copy it to .env file using the following command:
2019-08-31 22:25:25 +00:00
2024-07-31 22:49:46 +00:00
```bash
cp .env.example .env
```
2021-02-28 23:15:01 +00:00
2024-07-31 22:49:46 +00:00
The default values in the .env file are suitable for the docker-compose setup.
2021-02-28 23:15:01 +00:00
2024-07-14 21:14:07 +00:00
2. Migrate
2021-02-28 23:15:01 +00:00
2024-07-31 22:49:46 +00:00
```bash
2024-12-25 23:03:26 +00:00
just manage migrate
2024-07-31 22:49:46 +00:00
```
2021-02-28 23:15:01 +00:00
2024-07-14 21:14:07 +00:00
3. Run the development server
2021-02-28 23:15:01 +00:00
2024-07-31 22:49:46 +00:00
```bash
2024-12-25 23:03:26 +00:00
just run
2024-07-31 22:49:46 +00:00
```
#### Building and running other things
2024-07-14 21:14:07 +00:00
```bash
2024-07-31 22:49:46 +00:00
# Build the containers
2024-12-25 23:03:26 +00:00
just build
2024-07-31 22:49:46 +00:00
# Create a superuser
2024-12-25 23:03:26 +00:00
just manage createsuperuser
2024-07-31 22:49:46 +00:00
# Create Django migrations (after this, maybe you need to change file permissions in volume)
2024-12-25 23:03:26 +00:00
just manage makemigrations
2024-07-14 21:14:07 +00:00
```
2019-08-31 22:25:25 +00:00
2024-12-25 23:03:26 +00:00
### Using uv
2023-10-02 18:10:24 +00:00
2024-07-14 21:14:07 +00:00
#### Requirements
2023-10-02 18:10:24 +00:00
2024-07-14 21:14:07 +00:00
- Python 3.12 or higher
2024-12-25 23:03:26 +00:00
- [uv ](https://docs.astral.sh/uv/ )
2024-07-14 21:14:07 +00:00
- A running PostgreSQL server
2023-10-02 18:10:24 +00:00
2024-07-14 21:14:07 +00:00
#### Setup
2023-10-02 18:10:24 +00:00
2024-07-14 21:14:07 +00:00
1. Setup .env file
2023-10-02 18:10:24 +00:00
2024-07-31 22:49:46 +00:00
An example .env file is provided in the repository. You can copy it to .env file using the following command:
2023-10-02 18:10:24 +00:00
2024-07-31 22:49:46 +00:00
```bash
cp .env.example .env
```
2023-10-02 18:10:24 +00:00
2024-07-31 22:49:46 +00:00
Edit the .env file and set the values for the environment variables, especially the database variables.
2023-10-02 18:10:24 +00:00
2024-07-14 21:14:07 +00:00
2. Run migrate
2023-10-02 18:10:24 +00:00
2024-07-31 22:49:46 +00:00
```bash
2024-12-25 23:03:26 +00:00
uv run src/manage.py migrate
2024-07-31 22:49:46 +00:00
```
2023-10-02 18:10:24 +00:00
2024-07-14 21:14:07 +00:00
3. Run the development server
2023-10-02 18:10:24 +00:00
2024-07-31 22:49:46 +00:00
```bash
2024-12-25 23:03:26 +00:00
uv run src/manage.py runserver
2024-07-31 22:49:46 +00:00
```
2024-07-31 21:26:40 +00:00
2024-08-03 17:55:32 +00:00
### Updating requirements
2024-07-31 21:26:40 +00:00
2024-12-25 23:03:26 +00:00
We use uv. That means we have a set of loosely defined `dependencies` in `pyproject.toml` and lock dependencies in `uv.lock` .
2024-08-03 17:55:32 +00:00
2024-12-25 23:03:26 +00:00
To generate `uv.lock` run:
2024-07-31 21:26:40 +00:00
```bash
2024-08-03 17:55:32 +00:00
# Build requirements.txt etc
2024-12-25 23:03:26 +00:00
uv lock
2024-07-31 21:26:40 +00:00
2024-08-03 17:55:32 +00:00
# Build Docker image with new Python requirements
2024-12-25 23:03:26 +00:00
just build
2024-08-03 17:55:32 +00:00
```
2024-08-14 09:17:29 +00:00
## Important notes
* This project uses [django-zen-queries ](https://github.com/dabapps/django-zen-queries ), which will sometimes raise a `QueriesDisabledError` in your templates. You can find a difference of opinion about that, but you can find a difference of opinion about many things, right?
* If a linting error annoys you, please feel free to strike back by adding a `noqa` to the line that has displeased the linter and move on with life.