DEV Community

Redson Ngwira
Redson Ngwira

Posted on

Why Django Needs Convention Over Configuration (And How DJX Fixes It)

I've been building Django apps for a while now, and every single time I start a new feature, I do the same thing:

  1. Create a model
  2. Create views (ListView, DetailView, CreateView, UpdateView, DeleteView)
  3. Create templates for each view
  4. Create urls.py
  5. Wire it into the project urls.py
  6. Add the app to INSTALLED_APPS

Every. Single. Time.

Rails developers have been laughing at us for 20 years. They type one command:

bash

rails generate scaffold Post title:string content:text

And they're done.

Django Deserves Better

Django is more powerful than Rails in many ways. But the developer experience gap is real. There's no scaffolding. No conventions enforced by tooling. No "happy path" that just works.

So I built DJX.

What DJX Does

DJX is a CLI tool that brings convention over configuration to Django. Inspired by Rails, built for Django developers.

bash

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

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

What Gets Generated

When you run djx scaffold Post title:string content:text, DJX creates:

  • posts/models.py — model with all your fields + automatic created_at / updated_at
  • posts/views.py — all 5 class-based views
  • posts/templates/posts/ — list, detail, form, confirm_delete templates
  • posts/urls.py — all RESTful routes
  • Auto-wired into project urls.py
  • Auto-added to INSTALLED_APPS

Other Commands

bash

See all your routes in a clean table

djx routes

Remove a feature cleanly

djx destroy scaffold Post

Install a package and auto-add to INSTALLED_APPS

djx add djangorestframework

Generate just a model or just views

djx model Article title:string body:text
djx controller Post

The Comparison

Task Django DJX
New project django-admin startproject + manual setup djx new myproject
Full 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

It's Early Stage — Contributions Welcome

DJX is early stage and there's a lot to build. Ideas on the roadmap:

  • djx console — Django shell with all models auto-imported
  • djx generate api — DRF REST API scaffold
  • djx db migrate — shortcut for makemigrations + migrate

GitHub: https://github.com/RedsonNgwira/djx-cli

PyPI: https://pypi.org/project/djx-cli/

Built with ❤️ from Malawi 🇲🇼


What Rails-like features would you want in Django? Drop a comment below.

Top comments (0)