Repository navigation
Getting Started
This guide covers how to set up the project, run it locally, and make changes (Python, HTML, CSS).
See Git Workflow for how to share your changes, and Code Map to find your way around the code.
Before starting, make sure you have:
- Docker Desktop (must be running)
- Git
-
(Optional) Pixi — installed locally it helps with managing
pixi.lock, though Docker handles the runtime.
If you are cloning this repository for the first time (or setting up a new machine), follow these steps to initialize the environment.
-
Clone the repository
git clone https://github.com/ChristopherMarais/barkandambrosiagallery.git cd barkandambrosiagallery -
Create the
.envfileDocker Compose will not start without a
.envfile in the project root. For local development it only needs debug mode turned on. Without it, pages fail withMissing staticfiles manifest entry.DJANGO_DEBUG=True -
Build the environment
This builds the Docker container and installs the Python (Pixi) dependencies.
docker compose build
-
Install JavaScript dependencies
The Docker build does not install the npm packages that Tailwind needs. This puts them in
node_modules/in your project folder.docker compose run --rm web pixi run install-js
-
Initialize the database
Start the database and enable the
pg_trgmextension (the migrations add trigram indexes and fail without it). Then run the migrations to create the database schema.docker compose up -d --wait db docker compose exec db psql -U beetles_user -d beetles_db -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;" docker compose run --rm web pixi run migrate
-
Create an admin user
You need this to access the upload tools and admin panel.
docker compose run --rm web pixi run python manage.py createsuperuser
To view the website, start the containers. This runs the database and the Django web server.
docker compose up -d- View the site: http://localhost:8000
-
Read the emails it sends: http://localhost:8025. Mailpit, from
docker-compose.override.yml, catches every email locally (sign-up confirmations, approvals, password resets), so nothing is sent for real. -
Stop the site:
docker compose down(your database and uploads stay in Docker volumes).
Hot reloading: the project is configured to watch your folders. If you edit any .py file (views, models) or .html template, the server automatically reloads. Just refresh your browser.
Because we use Tailwind, changing classes in HTML (e.g. text-red-500 to text-blue-500) requires recompiling the CSS file.
- Open a new terminal window.
- Run the CSS watcher:
This runs in "watch mode" (it stays open — press
docker compose run --rm web pixi run watch-css
Ctrl+Cto stop it). As you save HTML or JS files, it regeneratesstyle.cssinstantly. - For a one-time rebuild without watching, use
pixi run build-cssinstead ofpixi run watch-css.
If you edit models.py (e.g. adding a new field to Beetles), you must update the database schema.
-
Create the migration file:
docker compose run --rm web pixi run python manage.py makemigrations
-
Apply the migration:
docker compose run --rm web pixi run migrate
-
Python: add the package to
pixi.tomlunder[dependencies], runpixi installlocally (if you have Pixi) to updatepixi.lock, thendocker compose buildto rebuild the container. -
JavaScript: edit
package.json, thendocker compose run --rm web pixi run install-jsto updatenode_modules/andpackage-lock.json.
docker compose run --rm web pixi run python manage.py test beetlesgallery --noinputMore on running and writing tests in Testing.
| Goal | Command |
|---|---|
| Start site | docker compose up |
| Stop site | docker compose down |
| Watch CSS | docker compose run --rm web pixi run watch-css |
| Rebuild CSS (once) | docker compose run --rm web pixi run build-css |
| Install JS dependencies | docker compose run --rm web pixi run install-js |
| Apply DB changes | docker compose run --rm web pixi run migrate |
| Create migration | docker compose run --rm web pixi run python manage.py makemigrations |
| Create admin (locally) | docker compose run --rm web pixi run python manage.py createsuperuser |
| Rebuild container | docker compose build |
| Run arbitrary command | docker compose run --rm web pixi run python manage.py <command> |
| Run tests | docker compose run --rm web pixi run python manage.py test beetlesgallery --noinput |
Next: read Contributing, then Git Workflow for how to share your changes.