Clone backend repository inside a folder
Clone the fronted repository inside the same root folder
Example:
projects
├───jstreet-backend
│ └───backend
└───jstreet-frontend
└───package.json
Copy .env.example to .env
Create the python virtual environment
python -m venv venv
Activate python virtual environment
Windows
.\venv\Scripts\activate
On Linux/macOS
source ./venv/bin/activate
Install libraries
pip install -r backend/requirements.txt
Run docker
Build docker compose build
Run docker compose up
Build and run docker compose up --build
Build and run production docker compose -f "docker-compose.prod.yml" up -d --build
Seeds data into Database
docker exec -it "container name or id" python manage.py loaddata api/fixtures/initial_data.json
Basic knowledge of python testing. https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Testing
Test URL example. http://localhost:8000/api/quick-answer-game/game-contents
Run specific test case example
docker exec -it "container name or id" python manage.py test api.tests.QuickAnswerGameTests.test_quick_answer_game_content
show all migrations
docker exec -it "container name or id" python manage.py showmigrations
create new migrations. for example, after adding change to model
docker exec -it "container name or id" python manage.py makemigrations
clear all migrations
docker exec -it "container name or id" python manage.py migrate api zero
migration
docker exec -it "container name or id" python manage.py migrate
Add a new super user
https://www.w3schools.com/django/django_admin_create_user.php
Add a normal user
After creating superuser, dump the data and change the flag for super user manually.
https://stackoverflow.com/questions/8017204/users-in-initial-data-fixture
Below are users.
IamSuper/password
studyman/studyman
learnLearn/learnLearn
In the case you can't run only with docker, you might need to define your ip adress correctly. Run this command and put your ip to env files for both frontend and backend.
Get-NetIPAddress
example result
IPAddress : 172.17.0.1
InterfaceIndex : 48
InterfaceAlias : vEthernet (WSL (Hyper-V firewall))
AddressFamily : IPv4
Type : Unicast
PrefixLength : 20
PrefixOrigin : Manual
SuffixOrigin : Manual
AddressState : Preferred
ValidLifetime :
PreferredLifetime :
SkipAsSource : False
PolicyStore : ActiveStore
The result of this command doesn't work well. Still searching.
docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 6b6cd1c04cf416cdfaf8d127bb1d507c6eed495058f2c22f0e3af12fd25fa47f
Django model https://www.geeksforgeeks.org/django-basic-app-model-makemigrations-and-migrate/
Django rollback migration https://sentry.io/answers/django-revert-last-migration/
Merge conflicts in migration https://www.algotech.solutions/blog/python/django-migrations-and-how-to-manage-conflicts/