Skip to main content

Auto-generate Django code via CLI/API - Models, Views, Admin, Forms, Auth, Middleware, Static

Project description

lazydjango

Cross-Platform Tests PyPI Version Python 3.10+ License: MIT

🚀 Auto-generate Django code via CLI, TUI, or Web API - Models, Views, Admin, Forms, Auth, Middleware

✨ Features

Code Generation

  • 📦 Model Generator - Create Django models with fields (CharField, TextField, ForeignKey, ManyToManyField, etc.)
  • 🎯 View Generator - Auto-generate CRUD API views (list, create, detail, update, delete)
  • ⚙️ Admin Generator - Generate Django admin configuration with list_display
  • 🎨 Form Generator - Create Django ModelForms and HTML templates
  • 🔐 JWT Auth Setup - Auto configure SimpleJWT authentication
  • 💅 Static Setup - Auto configure TailwindCSS or Bootstrap 5
  • 🔧 Middleware Generator - Generate custom middleware (logging, auth, rate limit, CORS)
  • 🌐 App Generator - Create new Django apps with automatic registration

API Server

  • FastAPI-powered REST API - All features accessible via HTTP endpoints
  • Built-in Web UI - Modern dark-themed Next.js interface (included in wheel)
  • Project Detection - Auto-detect existing Django projects with models and relationships
  • Database/ERD Tab - Visualize models and relationships in your project

Developer Experience

  • Bruno Docs - Auto-generate Bruno collection for API testing
  • TUI Mode - Text-based UI for terminal lovers
  • CLI Mode - Command-line interface for scripting

📦 Installation

pip install lazydjango

With development tools:

pip install lazydjango[dev]

🚀 Usage

Web UI (Recommended)

lazydjango web
# Then open http://localhost:8000

API Only

lazydjango web --api-only
# API available at http://localhost:8000/api/

TUI (Terminal UI)

lazydjango tui

CLI

lazydjango create-app blog
lazydjango create-model blog.Post title content
lazydjango create-views blog.Post --operations list,create,detail,update,delete
lazydjango create-admin blog.Post
lazydjango server start

📡 API Endpoints

Method Endpoint Description
GET /api/health/ Health check
GET /api/project/ Get project info with models
GET /api/project/apps/ List all apps
POST /api/apps/create/ Create new app
POST /api/models/create/ Create model with fields
POST /api/views/create/ Create CRUD views
POST /api/admin/create/ Create admin config
POST /api/forms/create/ Create forms & templates
POST /api/auth/setup/ Setup JWT auth
POST /api/static/setup/ Setup static files
POST /api/middleware/create/ Create middleware
POST /api/server/ Run Django commands
GET /api/bruno/ Get Bruno collection
GET /api/bruno/download/ Download Bruno JSON

📋 API Request Examples

Create App

curl -X POST http://localhost:8000/api/apps/create/ \
  -H "Content-Type: application/json" \
  -d '{"name": "blog", "project_path": "."}'

Create Model

curl -X POST http://localhost:8000/api/models/create/ \
  -H "Content-Type: application/json" \
  -d '{
    "app_name": "blog",
    "model_name": "Post",
    "fields": [
      {"name": "title", "field_type": "CharField", "max_length": 255},
      {"name": "content", "field_type": "TextField"}
    ],
    "migrate": true,
    "project_path": "."
  }'

Create Model with ForeignKey

curl -X POST http://localhost:8000/api/models/create/ \
  -H "Content-Type: application/json" \
  -d '{
    "app_name": "blog",
    "model_name": "Comment",
    "fields": [
      {"name": "text", "field_type": "TextField"},
      {"name": "post", "field_type": "ForeignKey", "related_model": "blog.Post", "on_delete": "CASCADE"}
    ],
    "migrate": true,
    "project_path": "."
  }'

Create Views

curl -X POST http://localhost:8000/api/views/create/ \
  -H "Content-Type: application/json" \
  -d '{
    "app_name": "blog",
    "model_name": "Post",
    "view_type": "template",
    "operations": {
      "create": true,
      "list": true,
      "detail": true,
      "update": true,
      "delete": true
    },
    "project_path": "."
  }'

Run Django Commands

# Check project
curl -X POST http://localhost:8000/api/server/ \
  -H "Content-Type: application/json" \
  -d '{"command": "check", "project_path": "."}'

# Run migrations
curl -X POST http://localhost:8000/api/server/ \
  -H "Content-Type: application/json" \
  -d '{"command": "migrate", "project_path": "."}'

🧪 Testing with Bruno

Download Bruno collection:

curl -o lazydjango-bruno.json http://localhost:8000/api/bruno/download/

Or import from the bruno/ folder included in the package.

📋 Requirements

  • Python 3.10+
  • Django 4.2+
  • FastAPI
  • Uvicorn

📄 License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lazydjango-1.0.0-py3-none-any.whl (277.9 kB view details)

Uploaded Python 3

File details

Details for the file lazydjango-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: lazydjango-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 277.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for lazydjango-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f4ce6977ae377ebc67de45a74ed309b360019984e8f62277511c0144575f6c0d
MD5 a5b7a2fbaa8a85dcc91b33489fa21746
BLAKE2b-256 98ebe9028f86de0b19ec6194dfe3f66488e9c6f300c8a313899f9c72d81a1191

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page