Simplify Django Setup with a Single Command

Django makes web development efficient, but its initial setup process involves running two commands:

django-admin startproject project_name  
cd project_name 
python manage.py startapp myapp

While simple, this two-step process could be streamlined into a single command. Imagine running:
django-admin startprojectwithapp myproject myapp
This unified command would:

  1. Create the project structure.
  2. Automatically generate the first app.
    The result? A ready-to-code project with less hassle:
project_name/  
    manage.py  
    myproject/  
        settings.py  
        urls.py  
        ...  
    myapp/  
        models.py  
        views.py  
        ...  

I believe combining django-admin startproject and python manage.py startapp into a single command would simplify the Django setup process and make development more efficient. I got it wrong when I started with django. I want to know what you guys think

Welcome @Brighht !

It is common for beginners to think that these two operations are joined or operate in parallel, but that’s not universally true.

You can run a Django installation without any user-written apps - where all apps being used are installed as packages. You’ll be running startproject only and never running startapp.

You may also be in a situation where you’re needing to create multiple apps for your project, and so want to run startapp multiple times without running startproject.

As a result of the effects of both of these situations, I believe it would be more confusing to add a third command to the mix.

2 Likes

Thank you, Ken! Your explanation really helped me understand it better. I’m still getting used to Django, but this makes things much clearer

There’s an effort going on, with two goals:

  1. Make startproject be enough to start with an app
  2. Make a new command that will make it easier to choose the kind of project

The work is done in a pull request on the DEPs repository. For readers who are not familiar with them – DEPs, or Django Enhancement Proposals, are specifications for major things in Django – major changes, basic processes etc.

The suggestion is a work in progress (that’s why it’s still a pull request), but it’s meant to address @Brighht’s initial complaint/suggestion – to make it more straightforward to start with the common case for beginners, while still keeping tabs on the somewhat-less-common cases @KenWhitesell noted.

2 Likes

Thank you. I’ll check it out