[Django Tutorial] Create a New Django Application. Drillthrough of the Project Directory

Welcome to the Blog Tutorial series of  Python Django Tutorial for Beginners. Previously we have covered all basic ideas of creating a new Django project, installing necessary modules which we will be working on, creating a superuser and little bit on database migration.

We also distinguished what a Django Project and Django App is. It’s recommended to go through the blogs from the beginning, if you are looking to Learn Django Application from beginning.

Creating a New Django Application

A Django application is created within a Django Project. We have covered the creation of Django application on our previous blog. Go check it out for a detailed explanation. In order to create a new application we can do it by manage.py startapp command like shown below:

python manage.py startapp applicationaname

Enter your desired application name. With this under your Django Project folder, you can see a folder created for the new app you just created.

Drillthrough of the New Application Directory

Your overall project structure till this phase is something similar to this:

VirtualEnvironmentDirectory
    bin
    etc
    include
    lib
    share
    src
       DjangoProjectFolder
           __init__.py
           settings.py
           urls.py
           wsgi.py
       DjangoAppFolder
           migrations 
           __init__.py
           admin.py
           apps.py
           models.py
           tests.py
           views.py
       db.sqlite3
       manage.py
    .gitignore
    requirements.txt
  1. All Folders are highlighted
  2. Five folders under the VirtualEnvironmentDirectory are created while we created a new Virtual Environment. (Activate Python Virtualenv / Virtual Environment in Linux? )
  3. Folder src is a custom folder which we created separate all software codes under src folder. Just to make the project structure look cleaner.
  4. DjangoProjectFolder is created while we created a new Django AProject with the help of Django Admin ( Install Django Framework, HelloWorld Django! )
  5. All our further instruction are installed using python manage.py  command, which lies under DjangoProjectFolder
  6. DjangoAppFolder is newly created folder for our new Django App we recently created.

Drillthrough of DjangoAppFolder

DjangoAppFolder is actually your new app name which you recently created. Within this folder you find following file and folders:

  1. Directory migration: which sill store all our database scheme changes we will make in our application.
  2. models.py sotres our database model for entire database.
  3. views.py is where we write code to render the views. HTML scripts can either be directly written in the views page or a different template can be included.

We will be further discussing on the components of our Application folder while implementing the views.

%d bloggers like this: