Development
Requirements
- Python 3.10
- virtualenv
- PostgreSQL
- virtualenvwrapper (optional, but recommended)
virtualenvwrapper
adds commands for naming, creating, listing, activating and deactivating
Python virtualenv
s, which makes it much easier to work on various Python projects.
If you prefer not to use it, any other way of creating a virtualenv
or venv will do.
Database setup
To create a new Blender ID database, run this as the PostgreSQL root user:
CREATE USER blender_id CREATEDB PASSWORD 'blender_id';
CREATE DATABASE blender_id OWNER blender_id;
CREATE SCHEMA blender_id;
GRANT ALL ON schema blender_id TO blender_id;
Password can be changed using the following:
ALTER ROLE blender_id WITH PASSWORD 'new_password';
In case of production, omit CREATEDB
and make sure that both postgres
and blender_id
users have secure hard to guess passwords set.
Development server setup
After cloning Blender ID repo, perform these steps to create a working dev server:
- Copy settings module
cp blenderid/__settings.py blenderid/settings.py
and adjust to your needs; - Run
git submodule update --init
; - Create a virtual environment with Python 3.10:
mkvirtualenv blender-id -a `pwd` -p /usr/bin/python3.10
pip install -r requirements_dev.txt
Note that path to python3.10
binary might differ in your OS, adjust the mkvirtualenv
command accordingly.
From this point on we assume you run everything with the virtual environment active.
- Run
./manage.py migrate
to migrate your database to the latest version; - Run
mkdir media
to create the directory that'll hold uploaded files, such as images for the badges; - Run
./manage.py createsuperuser
to create super user; - Load fixtures:
./manage.py loaddata default_site
./manage.py loaddata default_roles
./manage.py loaddata flatpages
- Run
./manage.py collectmedia
to collect media from fixtures and place into the media directory; - Add
127.0.0.1 id.local
to/etc/hosts
; - Run
./manage.py runserver
Devserver is now available at http://id.local:8000/
Setting up the Documentation system
We use mkdocs for documentation generation.
cd docs
directory- Run
mkdocs serve
and browse to the location suggested by the command output
TODO
- Check out the default management endpoints of the Django OAuth Toolkit.
Troubleshooting
"Site matching query does not exist."
Do this, activate Blender ID virtualenv environment and run:
./manage.py loaddata default_site
Then access your site at http://id.local:8000/. Add an entry to your hosts file if necessary.