Skip to main content

Convention over configuration for Django - Rails-like scaffolding and generators

Project description

djx-cli — Django Express

Convention over configuration for Django. Inspired by Ruby on Rails.

PyPI Python License: MIT

DJX Demo

3 commands. Full CRUD app. No boilerplate.

pip install djx-cli
djx new myblog && cd myblog
djx scaffold Post title:string content:text published:boolean
python manage.py migrate && python manage.py runserver
# → http://127.0.0.1:8000/posts/ — list, create, edit, delete. Done.

Why DJX?

Django is powerful but verbose. Starting a new feature means manually creating models, views, templates, URLs, and wiring them together. DJX does all of that in one command — the same way Rails has done it for 20 years.

Task Django DJX
New project django-admin startproject + manual venv + settings djx new myproject
New CRUD feature model + views + urls + templates (manual) djx scaffold Post title:string
See all routes no built-in command djx routes
Remove a feature delete files manually djx destroy scaffold Post

Installation

pip install djx-cli

Requires Python 3.8+ and works with Django 4.2+.


Quick Start

# 1. Create a new project — venv, Django, git, migrations all automatic
djx new myblog
cd myblog
source venv/bin/activate   # Linux/Mac
# venv\Scripts\activate    # Windows

# 2. Scaffold a full CRUD feature
djx scaffold Post title:string content:text published:boolean

# 3. Run migrations and start server
python manage.py makemigrations && python manage.py migrate
python manage.py runserver

Visit http://127.0.0.1:8000/posts/ — you have a working list, create, edit, and delete. No code written.


Commands

djx new <project>

Create a new Django project with everything configured.

djx new myproject

Creates: Django project, git repository, README, initial migrations. Asks if you want a virtual environment created automatically.


djx scaffold <Model> <fields>

Generate a complete CRUD feature — model, views, templates, and URLs all wired together.

djx scaffold Post title:string content:text published:boolean
djx scaffold Comment body:text author:string post:references:Post

Generates:

  • posts/models.py — model with all fields
  • posts/views.py — ListView, DetailView, CreateView, UpdateView, DeleteView
  • posts/templates/posts/ — list, detail, form, confirm_delete templates
  • posts/urls.py — all routes
  • Wired into project urls.py automatically
  • Added to INSTALLED_APPS automatically

djx model <Model> <fields>

Generate a model only (no views or templates).

djx model Article title:string body:text author:string

djx controller <Model>

Generate views and templates for an existing model.

djx controller Post

djx destroy <type> <Model>

Clean removal of a scaffold, model, or controller.

djx destroy scaffold Post    # removes app, URLs, INSTALLED_APPS entry
djx destroy model Post       # removes model only
djx destroy controller Post  # removes views and templates only

djx routes

Display all registered URL routes in a clean table.

djx routes
📍 Routes
URL Pattern              Name           View
=====================================================
posts/                   post-list      ListView
posts/<int:pk>/          post-detail    DetailView
posts/new/               post-create    CreateView
posts/<int:pk>/edit/     post-update    UpdateView
posts/<int:pk>/delete/   post-delete    DeleteView
✓ Total routes: 28

djx add <package>

Install a package and add it to INSTALLED_APPS automatically.

djx add django-crispy-forms
djx add djangorestframework

djx config <KEY> <value>

Set a value in settings.py from the terminal.

djx config DEBUG False
djx config ALLOWED_HOSTS '["*"]'

djx wire <app>

Manually wire an app's URLs into the project urls.py.

djx wire posts

Field Types

DJX type Django field
string CharField(max_length=200)
text TextField()
integer IntegerField()
boolean BooleanField()
date DateField()
datetime DateTimeField()
decimal DecimalField()
email EmailField()
url URLField()
references:Model ForeignKey(Model)

Project Structure

After djx new myblog && djx scaffold Post title:string content:text:

myblog/
├── manage.py
├── README.md
├── myblog/
│   ├── settings.py
│   └── urls.py
└── posts/
    ├── models.py
    ├── views.py
    ├── urls.py
    ├── migrations/
    └── templates/
        └── posts/
            ├── post_list.html
            ├── post_detail.html
            ├── post_form.html
            └── post_confirm_delete.html

Conventions

DJX follows these conventions so you don't have to think about them:

  • App name is the pluralized, lowercased model name (Postposts)
  • Templates follow app/model_action.html pattern
  • URLs follow RESTful patterns (/posts/, /posts/new/, /posts/1/edit/)
  • All models get created_at and updated_at automatically
  • Apps are auto-added to INSTALLED_APPS
  • URLs are auto-wired to the project urls.py

Contributing

Contributions are welcome! DJX is early-stage and there's a lot to build.

git clone https://github.com/RedsonNgwira/djx-cli.git
cd djx-cli
pip install -e .
djx --help

See CONTRIBUTING.md for guidelines.

Ideas for contributions:

  • djx console — Django shell with all models auto-imported
  • djx generate api — DRF REST API scaffold
  • djx server — runserver with better defaults
  • djx db migrate — shortcut for makemigrations + migrate
  • Windows compatibility improvements
  • More field types

License

MIT — see LICENSE.


Built with ❤️ from Malawi 🇲🇼 by Redson Ngwira

Project details


Download files

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

Source Distribution

djx_cli-0.1.5.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

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

djx_cli-0.1.5-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file djx_cli-0.1.5.tar.gz.

File metadata

  • Download URL: djx_cli-0.1.5.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for djx_cli-0.1.5.tar.gz
Algorithm Hash digest
SHA256 06d2ec73c8491e51b8c5cd9b2dbb925c84bb87ffc3885f9c795a2ff10de0a35e
MD5 30819f8f687d64c471d2538b43ac5456
BLAKE2b-256 8e308888641598cd81a62af71826e0b406926f7912b5afde3e8bfa47d8ee651c

See more details on using hashes here.

File details

Details for the file djx_cli-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: djx_cli-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for djx_cli-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1ebdc7da5a9ff3ad39af98c8a51033f081df68bb02cc287f12a6fb4584eedaf4
MD5 9bf605f6bc283bf9ddbf666e9a333971
BLAKE2b-256 b64d2011ee1523c7ded5b2bbae47ccae503b70a5e02deb68598c6d0447041c58

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