Skip to content

Latest commit

 

History

History
98 lines (57 loc) · 3.05 KB

README.md

File metadata and controls

98 lines (57 loc) · 3.05 KB

Python DjangoStatic Badge

noQ Backend (python)

noQ

Developer Guidelines

Create and Activate Virtual Environment

Create a virtual environment in the project directory and activate it:

python -m venv env

#On Windows:
env\Scripts\activate

#On Unix or macOS:
source env/bin/activate

Install Project Dependencies

Navigate to the project directory where the requirements.txt file is located and install required Python libraries listed in requirements.txt:

pip install -r requirements.txt

This command installs all the necessary packages specified in the requirements.txt file.

Database Initialization and Migration

Navigate to the directory containing manage.py and perform database migrations:

python manage.py makemigrations
python manage.py migrate
python manage.py runscript generate_data
python manage.py runscript generate_jobs
python manage.py runserver

These commands set up the database schema based on the Django models defined in the project. Qcluster is optional when testing and is used for automating periodic tasks

Create Local Superuser

python manage.py createsuperuser

API Endpoints

Access API documentation at http://localhost:8000/api/docs.

General naming for all APIs

/objects GET lists an object, with method name objects_list, can also have filter parameters
/objects/id GET retrieves a unique instance of object(/objects/id), with method name object_detail(id)
/objects/id POST creates an object, with method name object_add
/objects/id PATCH updates an object, with method name object_update(id)
/objects/id DELETE deletes an object, with method name object_delete(id)

Generate Random Data for Tests

python manage.py runscript delete_all_data
python manage.py runscript generate_data

All login credentials for generated users are stored in the fake_credentials.txt file located in the scripts folder.

Test Site

Access the test site at http://localhost:8000.

Running test cases

To run the test case for backend applications you can run following commands.

backend
python manage.py test backend
noq_django
python manage.py test noq_django

Troubleshooting

pkg_resources Module Error

If you encounter a ModuleNotFoundError related to pkg_resources during the migration make sure all dependencies, setup tools & pip are installed and up to date.

pip install setuptools
pip install --upgrade pip

Then retry running the migration commands .

Contributors

Made with contrib.rocks.