Backend API for the Norwegian public access TV channel Frikanalen.
If the server is run with uv run manage.py runserver, .env and .env.local are read, with .env.local taking precedence. If it is run in wsgi, only .env is used.
- ALLOWED_HOSTS - comma-separated list of permitted domains
- DATABASE_URL - database URL
- CACHE_URL - cache URL
- SMTP_SERVER - smtp server for outgoing email
To build a local copy:
docker build -t frikanalen/django-api .Then you can run it thus:
docker run -p 8080:8080 frikanalen/django-apiIf you set the environment variables $DJANGO_SUPERUSER_EMAIL and $DJANGO_SUPERUSER_PASSWORD, the user will be created if it does not exist.
Install the uv package manager.
# Create the virtual environment
uv venv
# Activate it
source .venv/bin/activate
# Install the packages in the lockfile
uv sync# Spin up PostgreSQL in Docker; web interface now at localhost:8082
docker-compose up -d
# Initialize the database
./manage.py migrate
# Load necessary fixtures (eg. content categories) into the database:
./manage.py loaddata frikanalenEITHER Load the testing users and organizations:
./manage.py loaddata test-usersOR Create a new admin user:
./manage.py createsuperuserStart the webserver:
./manage.py runserverPoint your browser to http://127.0.0.1:8000/admin and log in.
In addition to the HTTP API, the following commands are executed periodically as Kubernetes cron jobs in our cluster:
./manage.py fill_next_weeks_agendaThis job will fill the next week's schedule with videos as defined by the WeeklySlot model. This will generally be entries like "Fill Mondays 12-13 with the latest videos from NUUG".
./manage.py fill_agenda_with_jukeboxThis job will fill the remaining unpopulated areas with videos as randomly selected from the set of all videos marked with is_filler=True.
As a convenience a test data file has been supplied, eg. for integration testing.
It contains the following organizations:
- dev-org1
- dev-org2
Additionally, the following users:
- dev-admin@frikanalen.no site administrator
- dev-org1-admin@frikanalen.no administrator for org1
- dev-org1-member@frikanalen.no member of org1
- dev-org2-admin@frikanalen.no administrator for org2
For more advanced things you'd want to check our infrastructure Ansible setup.