How to Create a New Django Project in Linux via Command Line

Posted on

In this article, there will be a focus on the subject which is mainly about how to create a new Django project. But before starting on to create a new project based on Django web-based framework, try to execute the command of ‘django-admin’. It is a command which is used and it is hold th emain role for creating a new project using Django web-based framework. It is achieved by installing Django web-based framework and it can be referred from an article titled ‘How to Install Django in Linux via Command Line’ in this link.

Below is the execution of the command ‘django-admin’ just to make sure that the command is available and it exists to be able to be used to create a new project using Django web-based framework :

user@hostname:~$ django-admin

Type 'django-admin help <subcommand>' for help on a specific subcommand.

Available subcommands:

[django]
check
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
makemigrations
migrate
runserver
sendtestemail
shell
showmigrations
sqlflush
sqlmigrate
sqlsequencereset
squashmigrations
startapp
startproject
test
testserver
Note that only Django core commands are listed as settings are not properly configured (error: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.).
user@hostname:~$

As shown in the above output command, the command ‘django-admin’ exist and it can be used to create a new project. Below is the execution of the command for creating a new project using Django web-based framework. The command pattern is shown below :

django-admin startproject project_name

Below is the example of creating a new project using Django web-based framework :

user@hostname:~/apps$ django-admin startproject todolist
user@hostname:~/apps$ cd todolist/
db.sqlite3  manage.py  todolist
user@hostname:~/apps$

The above is an example of creating a new project using Django web-based framework with the name of the project is ‘todolist’. After finishing on creating the project, check the content of the project. The content of the folder created which the name of it is also taken from the parameter and in this context it is ‘todolist’ basically contains the above files and folders. It is a file named ‘db.sqlite3’, a file named ‘manage.py’ and a folder which has the same name as the project name given where in the context of this article it is ‘todolist’.

2 thoughts on “How to Create a New Django Project in Linux via Command Line

Leave a Reply