Basic Django project setup for the True Safeguard website.
- Create and activate the virtual environment:
- Linux/macOS:
python3 -m venv .venvsource .venv/bin/activate
- Install dependencies:
pip install django
- Run migrations and start the server:
python manage.py migratepython manage.py runserver
Open http://127.0.0.1:8000/ to see the home page.
We have switched to a Dockerized setup to ensure environment consistency.
-
Pull the latest changes:
git checkout maingit pull origin main
-
Create your .env file: Create a file named .env in the root directory and add:
DEBUG=TrueSECRET_KEY=local-dev-key-123DJANGO_ALLOWED_HOSTS=localhost,127.0.0.1,0.0.0.0
-
Build the image:
docker build -t django-app .
-
Start the container with the following command:
docker run -p 8000:8000 --env-file .env django-app
Migrations: Database migrations run automatically on startup.
- URL: Visit http://localhost:8000 to see the site.
To run commands inside the running container (e.g., creating a user):
docker exec -it $(docker ps -q --filter ancestor=django-app) python manage.py createsuperuser