3.9
python -m venv .venv
.venv\Scripts\activate
python -m pip install --upgrade pip
pip install -r requirements.txt
python manage.py migrate
python manage.py runserver
Just press F5 (Config is inside .vscode/
)
Please contribute if you know how.
Default variables should work out of the box already, but in case you want to customize, here is how.
Add .env
file and write your custom variables to it.
Available variables and their data type can be seen in companion/settings.py
:
env = environ.Env(
... # Variables are listed here
)
You can login to the browsable API and explore it to help with development.
python manage.py collectstatic
Go to this URL in your brower. (You may need to register new user and then login if you haven't already)
http://localhost:8000/
NOTE This is only needed if you develop features involving background tasks, like sending email, .etc
docker run -d --name rabbitmq -p 5672:5672 rabbitmq
Exec into container
docker exec -it rabbitmq bash
Create user, vhost
rabbitmqctl add_user companion_user companion_password
rabbitmqctl add_vhost companion_vhost
rabbitmqctl set_permissions -p companion_vhost companion_user ".*" ".*" ".*"
celery --app companion worker --loglevel INFO --pool solo
NOTE Every time you make changes to a task, celery worker should be restarted.
In development, emails are not actually sent, but instead saved to temp/sent_emails
.
You can inspect this directory to test email sending features.
python manage.py test
coverage run
coverage html
Your report is inside htmlcov
directory.
Run this command to collect locale messages to locale/<locale name>/LC_MESSAGES/django.po
of each app.
python manage.py makemessages --locale <locale name>
Compile locale messages to .mo
files.
python manage.py compilemessages --locale <locale name> --ignore .venv
In development, sqlite is used as DB. In production, if you want to use a different DB, remember to install the appropriate DB client.
Example: for MySQL, you need pip install mysqlclient
In production, only staff users can access browsable API.
To create staff user:
python manage.py createsuperuser