Create an application in Django
Django is famous for its unique and fully managed application structure. For each functionality, an application can be created as a completely independent module. This article will take you through how to create a basic application and add functionalities using that application.
For example, if we are creating a Blog, Separate modules should be designed for Comments, Posts, Login/Logout, etc. In Django, these modules we called an apps. There is a different app for each
Benefits of using Django apps
- Django app can be used with various projects.
- We has loosely coupled i.e. almost free(independent) components
- Many developers can work on different segments
- Debugging and code organisation is easy. Django has excellent debugger to
Django stores some pre-installed apps for users.
To see pre-installed apps, we have to navigate projectName -> settings.py
- In your settings.py file, you will find INSTALLED_APPS. Apps listed in INSTALLED_APPS are provided by Django for developers comfort.
Building an app Django
To create Django project we need to go to directory containing manage.py and from there enter the command
python manage.py startapp projectAp
To consider the app in project we need to specify your project name in INSTALLED_APPS list as follows in settings.py
INSTALLED_APPS = [
So, we have finally created an app, but to render the app using URLs, we need to include the app in our main project so that URLs redirected to that app can be provided. Let us explore it.
from django.contrib import admin
from django.urls import path,
urlpatterns = [
# Enter the app name in following syntax for this to work
Note:-The main feature of Django it is independent