How to Create a New Application using Django Web-based Framework in Ubuntu Linux via Command Line

Posted on

There is a term which is used in the web application development using Django as its main web framework. The first term is ‘project’ which is actually a must or a necessary requirement in order to create a new application or module. In order to create a new project, just read the article titled ‘How to Create a New Project using Django Web-based Framework in Ubuntu Linux via Command Line. So, another term besides ‘project’, there is a term for ‘app’. This is actually a term associated to an application or a module which is located inside the folder named ‘project’ which has been created in the first place. For the command used for creating a new application or module in a web-based project using Django as its main web framework, it can be shown as follows :

django-admin startapp app_name

The actual command is shown after being executed as follows :

user@hostname:~/test/myproject$ django-admin startapp apps
user@hostname:~/test/myproject$

The content of the new folder created by executing the above command can be shown in the following output :

user@hostname:~/test/myproject/apps$ ls
admin.py  apps.py  __init__.py  migrations  models.py  tests.py  views.py
user@hostname:~/test/myproject/apps$ 

The following are the command executed to see the actual content inside the already created application named ‘apps’ :

user@hostname:~/test/myproject/apps$ tree -L 2 .                                                                                                                                                                            
.                                                                                                                                                                                                                                 
├── admin.py                                                                                                                                                                                                                      
├── apps.py                                                                                                                                                                                                                       
├── __init__.py                                                                                                                                                                                                                   
├── migrations                                                                                                                                                                                                                    
│   └── __init__.py                                                                                                                                                                                                               
├── models.py                                                                                                                                                                                                                     
├── tests.py                                                                                                                                                                                                                      
└── views.py
1 directory, 7 files
user@hostname:~/test/myproject/apps$ 

Off course before the above steps can be executed, starting from the step of creating a new project, continued with the step of creating a new application or a new module, it must be preceeded with several important steps. Those steps are :

1. The availability of Python installed. One or another, the simplest way to check the python’s installation or the existence of python can be checked by executing the command ‘python -version’. For an example :

user@hostname:~/test/myproject/apps$ python --version
Python 2.7.12
user@hostname:~/test/myproject/apps$

2. The availability of Django installed. This is actually the installation of Django web-based framework itself. In order to check the installation of Django whether it has already installed or not, just type ‘django-admin -version’.

user@hostname:~/test/myproject/apps$ django-admin --version
1.9.4
user@hostname:~/test/myproject/apps$

One thought on “How to Create a New Application using Django Web-based Framework in Ubuntu Linux via Command Line

Leave a Reply