Yet Another Harry Potter Quiz (Backend)
This repository contains the Django
backend code for the yahpq.rocks website.
Versions
- Python- v3.7
- Django - v3.0.7
- Django REST Framework - v3.11.0
- Clone the repository using
git clone https://github.com/AbhishekPednekar84/hpquiz-rest-api
- Create a virtual environment with
python -m venv venv
- Activate the virtual environment with
venv\Scripts\activate
(Windows) orsource venv/bin/activate
(Linux / OsX) - Install the project dependencies using the command
pip install -r requirements.txt
The project uses a PostgreSQL
database with the connection string details stored in a .env
file
- Create a
.env
file in the project root folder and add theSECRET_KEY
and the database specific environment variables (please refer to the.env.example
file). If using another database engine, modify the details accordingly. cd
to thequiz_api_manager
directory- Create a migration using the command
python manage.py makemigrations
- Run the migration with
python manage.py migrate
- Create a superuser by running
python manage.py createsuperuser
- Run the application using
python manage.py runserver
- Assuming that the application is running on the default port
8000
, theSwagger
documentation should now be visible athttp:\\localhost:8000
The project uses the django-cors-headers
library to talk to the Reactjs
frontend.
- If the frontend is running on a port other than
3000
, modify theCORS_ORIGIN_WHITELIST
property insettings.py
- Add data using the
django shell
or via https:\localhost:8000\admin
The project uses the pytest-django
library to run test cases. To run a test, cd
to the quiz_api_manager
directory and run the pytest
command