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 db

Shortcut for the most common database workflow.

djx db          # makemigrations + migrate in one command
djx db reset    # flush + migrate (wipe and rebuild)

djx console

Django shell with all your models already imported — no manual imports needed.

djx console
# ✓ Models loaded: Post, Comment, User
# >>> Post.objects.all()

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.9.tar.gz (16.8 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.9-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: djx_cli-0.1.9.tar.gz
  • Upload date:
  • Size: 16.8 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.9.tar.gz
Algorithm Hash digest
SHA256 e954ea23fafa856dbdc44cd8b10550eb2af6c5039aa06144d5b52c22693ff900
MD5 28e35085b4064496f5584dd73427a938
BLAKE2b-256 5aecee9214a168fa1dda69fc419c88725b3ac817accd925ea9cb00aa3fb89389

See more details on using hashes here.

File details

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

File metadata

  • Download URL: djx_cli-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 18.1 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.9-py3-none-any.whl
Algorithm Hash digest
SHA256 394f70746df856da652366b4c6e15667bc2442375cbdc2e82c892ca99fbcc8a5
MD5 f29a50fc288a359a92c56e0f1166b0f8
BLAKE2b-256 f0b51a1d9226b48e9e86a5ec3dd37b198ee68aa6b081cde2ae1aebd82b012450

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