Installation
To get started with the FandomHub API, follow these steps to set up your development environment and get the application running smoothly.
⚙️ Installation
Clone the repository.
git clone git@github.com:tyronejosee/project_fandomhub_api.git
Create a virtual environment (Optional).
python -m venv env
Activate the virtual environment (Optional).
env\Scripts\activate
Install all dependencies.
pip install -r requirements/local.txt
Create an environment variable file .env
.
SECRET_KEY=""
EMAIL_BACKEND=""
EMAIL_HOST=""
EMAIL_HOST_USER=""
EMAIL_HOST_PASSWORD=""
EMAIL_PORT=""
EMAIL_USE_TLS=""
Docker run.
(env) docker compose -f docker-compose.dev.yml up
(env) docker compose -f docker-compose.dev.yml up --build
(env) docker compose -f docker-compose.dev.yml stop
(env) docker compose -f docker-compose.dev.yml logs -f
(env) docker compose -f docker-compose.dev.yml start
(env) docker compose -f docker-compose.dev.yml restart <service>
Perform database migrations.
(env) docker compose -f docker-compose.dev.yml exec web bash
(env) docker compose -f docker-compose.dev.yml exec web python manage.py makemigrations*
(env) docker compose -f docker-compose.dev.yml exec web python manage.py migrate
(env) docker compose -f docker-compose.dev.yml exec web python manage.py migrate <app_label> <migration_name>
(env) docker compose -f docker-compose.dev.yml exec web python manage.py showmigrations
Note: Create the migrations in case Django skips any.
🚀 Usage
Create a superuser to access the entire site without restrictions.
(env) docker compose -f docker-compose.dev.yml exec web python manage.py createsuperuser
Log in to /admin
:
http://127.0.0.1:8000/admin/
Access to Swagger o Redoc.
http://127.0.0.1:8000/api/schema/swagger/
http://127.0.0.1:8000/api/schema/redoc/
🌍 Internationalization
Generate translation files for the languages.
(env) django-admin makemessages -l ja --ignore=env/*
(env) django-admin makemessages -l es --ignore=env/*
Use
--ignore
to exclude specific directories from translation.
Compile translation files after making changes to translations.
(env) django-admin compilemessages
🚨 Important Notes
Check the creation of migrations before creating them.
(env) docker compose -f docker-compose.dev.yml exec web bash
(env) docker compose -f docker-compose.dev.yml exec web python manage.py makemigrations users
(env) docker compose -f docker-compose.dev.yml exec web python manage.py makemigrations
(env) docker compose -f docker-compose.dev.yml exec web python manage.py migrate
Note: Checking migrations before their creation is necessary to avoid inconsistencies in user models.
💾 PostgreSQL
(env) docker compose -f docker-compose.dev.yml exec web python manage.py dumpdata > backup.json
(env) docker compose -f docker-compose.dev.yml exec web python manage.py loaddata
(env) docker compose -f docker-compose.dev.yml exec db psql -U postgres -d fandomhub_db
(fandomhub_db=#) \dt
(fandomhub_db=#) \d <table>
💾 Redis
(env) docker compose exec redis redis-cli
(127.0.0.1:6379) keys *
⚖️ License
This project is under the Apache-2.0 license.
🌱 Contributing
- Fork the repository.
- Create a new branch (
git checkout -b feature/new-feature
). - Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature/new-feature
). - Open a Pull Request.