How to start the development server - GermanZero-de/localzero-monitoring GitHub Wiki
Start the development server
We roughly follow some of the project layout / config layout ideas of the Two Scoops of Django book (https://www.feldroy.com/books/two-scoops-of-django-3-x).
So the configuration lives in config/settings/
. Most importantly that means when testing locally you want to do this:
# enter the poetry python environment
eval $(poetry env activate)
# install css and javascript libraries
yarn install
# prepare the database
python manage.py migrate --settings=config.settings.local
# install example data
python manage.py loaddata --settings=config.settings.local e2e_tests/database/test_database.json
cp -r e2e_tests/database/test_database_uploads/. cpmonitor/images/uploads
# start the backend server
python manage.py runserver --settings=config.settings.local
cd frontend/
npm install
# start the frontend devserver (configured to load images from production)
npm run dev
# alternatively, start the frontend devserver (loading images from backend)
npm run dev-local
Whenever you have problems make sure that you have activated the virtual environment correctly. You may have to
deactivate it with deactivate
and activate it with eval $(poetry env activate
.
The two frontend configurations are used for different scenarios:
- if you downloaded the production database to your machine and you obly want to work on the frontend, use
npm run dev
- otherwise, use
npm run dev-local
to work on both frontend and backend, and use the data in the test database instead of production data
Login to the admin site
The admin user for development is:
- user name: admin
- password: password
or create a new admin user with:
python manage.py createsuperuser --settings=config.settings.local
(Windows: prepend winpty
)