Django Multiple Apps in one Project | Django Tutorials
May 14, 2021 2023-04-08 11:59Django Multiple Apps in one Project | Django Tutorials
Django Multiple Apps in one Project | Django Tutorials
Django Multiple Apps in one Project | Django Tutorials
As you have read the post title that Django Multiple Apps in one Project, it means, you will learn to create the application in Django project but more than one.
In the previous tutorials, we were discussing creating a single application in a single project but now we want to learn more techniques and concepts with examples. So let’s start from the basic level to reach our targets!
You know Django is the Python-based web framework that is the most used python framework. As it has powerful libraries related to Artificial intelligence, machine learning, etc. and also spread due to its easiness, security, user-friendly, etc.
In the previous Django tutorial, we have learned that how to create an application in the Django project but now we will learn that how to create multiple apps in one Django project.
The following command is used to create an application in your Django project, now
python manage.py startapp app_name
It will create an application in your Django project, then the next step is to include your application in Django installed app list as located in the settings.py file. As shown in following
INSTALLED_APPS = [ … ‘app_name’,
, … ]
For example:
python manage.py startapp scool
So, our project is the ‘school, when you run this command, you will get a folder with the school name, in which all the default files you will get. So, this ‘school’ name you should add in settings.py file
python manage.py startapp alnoor
Another example, in this case, our application name is the alnoor which is a may ba organization. So, you will add it in the settings.py file also.
If you want to create another application then run the same command again changing your application name, then same like before, add your application in the installed app list.
Your installed app list should be like this one in case of multiple application
INSTALLED_APPS = [ …
‘app_name’,
‘app_name1’,
‘app_name2’,
, … ]
In our case of examples as mentioned here:
INSTALLED_APPS = [ …
‘school’,
‘alnoor’,
]
Important note:
Sometimes we create applications but we forget to add in INSTALLED_APPS = [‘….’], due to this you face problems because Django doesn’t about your application because you have to inform as you create a new application. Then add in INSTALLED_APPS = [].
And also care of commas while adding the 2nd application, because you are adding an application in Python list structure that needs a comma after one item.
Further Discussion | Django Multiple Apps in one Project
Now you have included multiple applications separating with comma. It becomes very necessary to add multiple apps in a single Django project because maybe, you develop a huge web application that needs a lot of modules, then it is your responsibility to manage everything in the project.
Because if you did not manage all the modules then it will become very difficult for you to organize your project code.
And also be aware, when you create multiple applications then you must include a separate template folder inside each application. It means each application should have a template folder for its own web pages. For example, your application name is ‘registration’ then inside your application > template folder > here your folder name should be ‘registration’ for storing template files.
Also, Learn:
What is Django template | Django Tutorials
Conclusion
You have understood about creating Django Multiple Apps in one Project and its importance. And also keep updated, because we update our tutorials in order to add more concepts, knowledge, experiences, and information for our readers and beginners students.
So, if you have any questions or confusion then must share with us, we try to find out the best solution for you.
Recommended Django tutorials for you
Ultimate Guide | Creating Application in Django | Django commands
Complete Django Template Language Tutorial (DTL)