Django Tips: Starting a project

We all know how easy it is to start a project in Django. After installing Django you just need to issue one command:

django-admin sartproject myproject

This will create a myproject directory in your current directory which will contain some initial settings, database configurations etc. and the structure is as follows:

myproject
├── manage.py
└── myproject
├── __init__.py
├── settings.py
├── urls.py
└── wsgi.py

Here you can see there is a myproject on top of all, which contains another myproject inside. This inside myproject will contain the settings and configurations.

Somehow I’ve developed a bit of compulsion towards this structure of myproject inside myproject. I wanted to rename this inside one as root or main or anything that doesn’t matches with the parent directory name. In the start I used to rename the myproject inside then change some line in the settings.py , manage.py and wsgi.py. It was not that difficult but I wanted Django to take care of that for me. And It’s very easy. You just need to issue one more command.

Let’s assume that you want to create a project that’s settings and configurations folder will be named as root. So first, you need to create a directory by yourself where the project will reside. Then run the same command as creating project, this time just specify the name of settings and configurations directory. Like this:

mkdir myproject
django-admin startproject root myproject

And the resultant structure is:

myproject
├── manage.py
└── root
├── __init__.py
├── settings.py
├── urls.py
└── wsgi.py

Does it looks and sounds better?

Happy coding!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store