[Django] #36444: Ticket: Create Custom Django Management Command for Project + App Setup

4 views
Skip to first unread message

Django

unread,
Jun 6, 2025, 8:16:02 AM6/6/25
to django-...@googlegroups.com
#36444: Ticket: Create Custom Django Management Command for Project + App Setup
-------------------------------------+-------------------------------------
Reporter: lothartj | Owner: lothartj
Type: New | Status: assigned
feature |
Component: | Version: 5.1
Internationalization | Keywords: command-line,
Severity: Normal | startproject, startapp
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
The current workflow for starting a new Django project requires multiple
commands:
{{{
django-admin startproject myproject
cd myproject
python manage.py startapp myapp
}}}

Then manually adding the app to `INSTALLED_APPS`.

This patch adds a new `create` management command that combines these
steps into a single command:
{{{
django-admin create myproject myapp
}}}

Features:
* Creates both project and app in one command
* Automatically adds app to `INSTALLED_APPS`
* Maintains existing settings.py formatting
* Includes comprehensive test coverage
* Backwards compatible (existing commands remain unchanged)

Usage:
{{{
# Basic usage
django-admin create myproject myapp

# With optional directory
django-admin create myproject myapp --directory /path/to/directory
}}}

The command:
1. Creates a new project using `startproject`
2. Creates a new app using `startapp`
3. Automatically adds the app to `INSTALLED_APPS` in settings.py
4. Maintains proper indentation and quote style in settings.py

Test coverage includes:
* Basic project and app creation
* Directory handling
* Error cases
* Output messages
* INSTALLED_APPS formatting

Patch includes:
* New management command: `django/core/management/commands/create.py`
* Test suite: `django/tests/user_commands/tests.py`
--
Ticket URL: <https://code.djangoproject.com/ticket/36444>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Reply all
Reply to author
Forward
0 new messages