Day 5 of 100 Days of Django: What are Applications and it’s Directory Structure.
Hi🙋♂️ Devs, so let’s discuss What is Django application and it’s significance.
A Django project💻 contains one or more applications which means we create multiple applications inside Project Folder.
Applications are a separate part of a Django Project which are portable to other django projects🧑💼 so that we can reuse them.
We can create any number of applications😱 in project according to requirement.
Syntax:
- Create one application inside project folder
python manage.py startapp app_name
- Create multiple application inside project folder
python manage.py startapp app_name1
python manage.py startapp app_name2
In order to use above created application we need to install them in our project:
Steps: 🤗
- Step 1: open settings.py file🙂
- Step 2:
INSTALLED_APPS =
[ 'django.contrib.admin',
....,
'app_name1',
'app_name2', ]
- Step 3: Save it✨.
Application Folder Directory Structure🔥
- migrations — This folder contains init.py file which means it’s a python package. It also contains all files which are created after running the makemigrations command.
- __init__.py — The folder which contains init.py file is considered as python Package.
- admin.py → This file is used to register SQL tables so we could perform CRUD operations from Admin Application. Admin application is provided by Django to perform CRUD operation
- apps.py → This file is used to config app when using Django Signals.
- models.py → This file is used to create our own model classes later these classes will be converted into database table by Django for our application.
- tests.py → This file is used to create test cases for Model, API and signals etc.
- views.py → This file is used to create view. We write all the business logic related code in this file.
Thanks for Following and Claps😋
Link to Day 6