https://github.com/tyronejosee/prototype_django_mysql
Prototype for a Django web application with MySQL, containerized using Docker Compose for easy setup and deployment.
https://github.com/tyronejosee/prototype_django_mysql
django docker docker-compose mysql python
Last synced: about 1 hour ago
JSON representation
Prototype for a Django web application with MySQL, containerized using Docker Compose for easy setup and deployment.
- Host: GitHub
- URL: https://github.com/tyronejosee/prototype_django_mysql
- Owner: tyronejosee
- License: apache-2.0
- Created: 2025-05-28T22:35:47.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-30T00:01:44.000Z (about 1 year ago)
- Last Synced: 2025-10-27T23:41:31.313Z (8 months ago)
- Topics: django, docker, docker-compose, mysql, python
- Language: Python
- Homepage:
- Size: 17.6 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Prototype Django MySQL
## ⚙️ Installation
Clone the repository.
```bash
git clone git@github.com:tyronejosee/prototype_django_mysql.git
```
Create a virtual environment (Optional, only if you have Python installed).
```bash
python -m venv env
```
Activate the virtual environment (Optional, only if you have Python installed).
```bash
env\Scripts\activate
```
> Notes: `(env)` will appear in your terminal input.
Install all dependencies (Optional, only if you have Python installed).
```bash
pip install -r requirements/local.txt
```
Create a copy of the `.env.example` file and rename it to `.env`.
```bash
cp .env.example .env
```
**Update the values of the environment variables (Important).**
> Note: Make sure to correctly configure your variables before building the container.
## 🐳 Docker
Build your container; it will take time the first time, as Docker needs to download all dependencies and build the image.
Use the `-d` (detached mode) flag to start your containers in the background.
Use the `--build` flag if you have changes and need to rebuild.
```bash
docker compose up
docker compose up -d
docker compose up --build
```
Stop the running containers (does not remove them).
```bash
docker compose stop
```
Start previously created and stopped containers.
```bash
docker compose start
```
Show container logs in real-time.
```bash
docker compose logs -f
```
Restart a service with issues (Replace ``).
```bash
docker compose restart
```
Remove your container.
```bash
docker compose down
```
## 🐍 Django
Access the `web` service console that runs Django.
```bash
docker compose exec web bash
```
Inside the Django console, create the migrations.
```bash
python manage.py makemigrations
```
Run the migrations.
```bash
python manage.py migrate
```
If you need to be more specific, use:
```bash
python manage.py migrate
```
List all available migrations and their status.
```bash
python manage.py showmigrations
```
> Note: Manually create the migration if Django skips an app; this happens because Django did not find the `/migrations` folder.
Create a superuser to access the entire site without restrictions.
```bash
python manage.py createsuperuser
```
Log in to `admin`:
```bash
http://127.0.0.1:8000/admin/
```
Access Swagger or Redoc.
```bash
http://127.0.0.1:8000/api/schema/swagger/
http://127.0.0.1:8000/api/schema/redoc/
```
## 🚨 Important Notes
Check the creation of migrations before creating them.
```bash
docker compose exec web python manage.py makemigrations users
```
> Note: Checking migrations before their creation is necessary to avoid inconsistencies in user models.
## 🐘 PostgreSQL
Access the PostgreSQL console.
```bash
docker compose exec db psql -U postgres -d example_db
```
List all the tables in the database.
```bash
\dt
```
Show the detailed structure of a specific table.
```bash
\d
```
Create a backup of your database (Optional).
```bash
docker compose exec web python manage.py dumpdata > backup.json
```
Load the created backup if needed (Optional).
```bash
docker compose exec web python manage.py loaddata
```
## ⚖️ License
This project is under the [Apache-2.0 license](https://github.com/tyronejosee/prototype_django_mysql/blob/main/LICENSE).