A minimal full-stack application for managing products and orders using Django REST Framework and Vue 3 (Vite).
1. Prerequisites
- Python 3.10+
- uv (Fast Python Package Manager)
2. Installation
# Clone the repo and enter backend directory
cd backend
# Install dependencies using uv
uv sync
3. Configuration (settings.py)
Ensure corsheaders is configured to allow the Vue dev server:
INSTALLED_APPS = [..., "corsheaders", "rest_framework"]
MIDDLEWARE = ["corsheaders.middleware.CorsMiddleware", ...]
CORS_ALLOWED_ORIGINS = ["http://localhost:5173"]4. Run Server
python manage.py migrate
python manage.py runserver
1. Prerequisites
- Node.js 18+
- npm or pnpm
2. Installation
cd frontend
npm install
3. Environment Config
Ensure src/services/api.ts points to your Django server:
- Base URL:
http://localhost:8000/api
4. Run Dev Server
npm run dev
- Models: Custom User, Product, Order, and OrderItem (with Many-to-Many through table).
- Serializers: Nested relationships and
SerializerMethodFieldfor calculated totals. - API Views: Function-based views (
@api_view) for CRUD operations on Products and Orders.
- Composition API: Uses
<script setup lang="ts">for modern reactivity. - Axios Service: Centralized API client with TypeScript
interfacesupport. - Type Safety: Strict type checking for API responses using
import type.
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/products/ |
List all products |
POST |
/api/products/ |
Create a new product |
GET |
/api/orders/ |
List all orders with items and totals |
DELETE |
/api/orders/<id>/ |
Delete an order |