An open API service indexing awesome lists of open source software.

https://github.com/joacod/django-playground

Django playground
https://github.com/joacod/django-playground

django python3

Last synced: about 1 month ago
JSON representation

Django playground

Awesome Lists containing this project

README

          

# Django Playground

[![GitHub](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/joacod/django-playground/blob/main/LICENSE)

[![Python](https://img.shields.io/badge/python-3670A0?style=for-the-badge&logo=python&logoColor=ffdd54)](https://www.python.org)
[![Django](https://img.shields.io/badge/django-%23092E20.svg?style=for-the-badge&logo=django&logoColor=white)](https://www.djangoproject.com)
[![React](https://img.shields.io/badge/react-%2320232a.svg?style=for-the-badge&logo=react&logoColor=%2361DAFB)](https://react.dev/)
[![Docker](https://img.shields.io/badge/docker-%230db7ed.svg?style=for-the-badge&logo=docker&logoColor=white)](https://www.docker.com/)

## ๐Ÿ‘‹ Introduction

Full-stack Django project with React frontend, containerized with Docker for seamless development.

### Tech Stack

- ๐Ÿ **Backend**: Django + Django REST Framework + PostgreSQL
- โš›๏ธ **Frontend**: React + Vite + Tailwind CSS
- ๐Ÿณ **Development**: Docker + Docker Compose

### Development Features

- โœ… **Django**: Python code changes restart the server automatically
- โœ… **React**: Frontend changes update instantly in the browser
- โœ… **Database**: PostgreSQL with persistent data across restarts

## ๐Ÿš€ Quick Start (2 minutes)

### Prerequisites

Docker & Docker Compose installed

### Get Started

1. Create environment file **".env"** from **".env.example"**

2. Start everything with one command

```bash
docker-compose up --build -d
```

3. Access your applications

- ๐Ÿ Django: http://localhost:8000
- โš›๏ธ React Frontend: http://localhost:5173

That's it! Both applications are running with live reloading. ๐ŸŽ‰

## ๐Ÿ’ป Development Commands

Apply Django database migrations

```bash
docker-compose exec web python manage.py migrate
```

View logs

```bash
docker-compose logs web -f # Django logs
docker-compose logs frontend -f # React logs
```

Fresh start (removes database data)

```bash
docker-compose down -v && docker-compose up --build
```

## ๐Ÿ› ๏ธ Admin Panel

Create a superuser for Django admin

```bash
docker-compose exec web python manage.py createsuperuser
```

Access admin at: http://localhost:8000/admin

## ๐Ÿ—„๏ธ Database Management with pgAdmin

Analyze and manage your PostgreSQL database using pgAdmin web interface.

### Access pgAdmin

1. **Open pgAdmin**: http://localhost:5050
2. **Login credentials**:
- Email: `admin@admin.com`
- Password: `admin`

### Connect to PostgreSQL Database

1. Click **"Add New Server"** or **"Create > Server"**
2. **General tab**:
- Name: `Django Playground` (or any name you prefer)
3. **Connection tab**:
- Host name/address: `db`
- Port: `5432`
- Maintenance database: `django_playground`
- Username: `django_user`
- Password: `django_password`
4. Click **"Save"**

## ๐Ÿ“ Choosing Your Development Approach

This project supports **both** Django development approaches:

### ๐Ÿ **Django Templates Approach**

- **What**: Traditional server-side rendered HTML pages
- **Access**: http://localhost:8000
- **Use case**: Classic Django web applications with server-side rendering

### โš›๏ธ **API + React Frontend Approach**

- **What**: Django REST Framework APIs + React SPA
- **Access**:
- API: http://localhost:8000/api/
- Frontend: http://localhost:5173
- **Use case**: Modern decoupled architecture with React consuming DRF APIs

## ๐Ÿงช Testing

Run Django REST framework tests

```bash
docker-compose exec web python manage.py test -v 2
```

## โ˜•๏ธ Did you like the project?

You can collaborate with me giving a star โญ๏ธ to the project or

[!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/joacod)

Thanks! ๐Ÿ˜ƒ