Skip to content

RCSS-Tournament-Manager/manager-backend

Repository files navigation

Management-Backend

Welcome to the Management-Backend Django project repository. This README provides you with the necessary information to set up and contribute to the development of the Management-Backend application.

Prerequisites

Before you begin, ensure you have the following installed on your development machine:

  • Python 3.11.x (only this version)
  • pipenv
  • Docker and Docker Compose

Project Setup

1. Clone the repository

git clone https://github.com/RCSS-Tournament-Manager/manager-backend.git
cd management-backend

2. Install dependencies

We use pipenv to manage project dependencies and virtual environments. To install the required packages, run:

python -m pip install pipenv 
pipenv install --dev

3. Activate the pipenv shell

This will spawn a new shell subprocess, which can be deactivated by simply closing it, or by running exit.

python -m pipenv shell

4. Generate a secret key

Generate a Django secret key that will be used in your .env file:

```sh
python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'
```
Or use **openssl**
```sh
openssl rand -hex 32
```

5. Fill the .env file

Create a .env file in the root directory of the project and fill it with the necessary environment variables. Here's a template to get you started:

# Django settings
DEBUG=True
SECRET_KEY=<Your generated secret key>
ALLOWED_HOSTS=127.0.0.1,localhost

# Email settings for development
EMAIL_HOST=localhost
EMAIL_PORT=1025
EMAIL_HOST_USER=
EMAIL_HOST_PASSWORD=
EMAIL_USE_TLS=False

Replace <Your generated secret key> with the key generated in the previous step.

6. Set up the development database

We use SQLite for development purposes. To set up your database, run:

python manage.py migrate

7. Run the development server

To start the Django development server, run:

python manage.py runserver

The server will start at http://127.0.0.1:8000/.

API document http://127.0.0.1:8000/api/docs/swagger/#/api/api_schema_retrieve

7.1 Add new Superuser

python manage.py createsuperuser

8. Troubleshooting

8.1 ZoneInfoNotFoundError: 'No time zone found with key utc'

pip install tzdata

Solution for testing mail server

1- Mailhug (as Docker) 2- Mailpit (recommended) 3- MailTrap (External service)

1- Docker Compose (only for mail service)

The project includes a docker-compose.yml file which sets up all the necessary services for the application, including a mail service for development purposes.

To start all services, run:

docker-compose up -d

This command will start the services in detached mode. You can view the logs for the services using:

docker-compose logs -f

To stop the services, use:

docker-compose down

the mailhug service is available at http://127.0.0.1:8025/.

2- Mailpit directly as exe file

Mailpit is a small, fast, low memory, zero-dependency, multi-platform email testing tool & API for developers.

It acts as an SMTP server, provides a modern web interface to view & test captured emails, and contains an API for automated integration testing.

Mailpit was originally inspired by MailHog which is no longer maintained and hasn't seen active development for a few years now.

https://github.com/axllent/mailpit

3- MailTrap.io

also you can use any external service for testing smtp like mailtrap.io

Releases

No releases published

Packages

No packages published