Creating an App in Django

Creating an App in Django

Altaf Shaikh

Published on Mar 19, 2021

5 min read

Subscribe to my newsletter and never miss my upcoming articles

Listen to this article

Now that our environment -- a "project" -- is set up, we're set to start doing work. In this section, we will learn what is an App in Django and we will create an account App to handle the user signup feature. So let's get started.

What is App?

An App is a Web application that does something. So for every functionality, an app can be created like a completely independent module. Let's understand App in Django with this realistic example:

Say you are building an online shopping site (e-commerce site) in Django so our Project will consist of Apps like:

  • Cart:- Which would have logic for users selected items for purchase.

  • Products:- Which would have logic for products that the site is selling.

  • Profile:- Which would have logic for user information.

Each application you write in Django consists of a Python package that follows a certain convention. Django comes with a utility that automatically generates the basic directory structure of an app, so you can focus on writing code rather than creating directories.

Benefits of using Django apps --

  • Django apps are reusable i.e. a Django app can be used with multiple projects.

  • Components are almost independent

  • Multiple developers can work on different components

  • Debugging and code organization is easy.

How to create a Django App

To create your app, make sure you're in the same directory as **** and type this command:

python startapp account

That'll create a directory account, which is laid out like this:

  • - Just to make sure python handles this folder as a package.

  • - This file helps you make the app modifiable in the admin interface.

  • - This is where all the application models are stored.

  • - This is where your unit tests are.

  • - This is where your application views are (actual logic).

To consider the account app in your project you need to specify your app name in the INSTALLED_APPS list as follows in social/ file.








    #add the app name here



By default, INSTALLED_APPS contains the following apps, all of which come with Django:

These applications are included by default as a convenience for the common case.

Some of these applications make use of at least one database table or if our app makes use of database table (models), though, so we need to create the tables in the database before we can use them. To do that, we use the following command:

python migrate

The migrate command looks at the INSTALLED_APPS setting and creates any necessary database tables according to the database settings in your social / file.

Watch Out The Video

So in this section, we learn how to create an App in Django and how to configure the App inside the settings. In the next section, we will learn about **Models** and we will write our first **Model** in Django.

Share this