What are the pre-installed apps that Django provides?
users get some pre-installed apps provided by Django. for viewing the pre-installed apps, follow the below-mentioned steps -
- Navigate to project name, then go to seetings.py
- Furthermore, now you will see INSTALLED_APP in the settings.py file.
- Django provides listed apps names in the INSTALLED _APP for the developer's comfort.
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles'
]

You can also try this code with Online Python Compiler
Run Code
How to create an app in Django?
So we will go through 2 different methods for making an app in Django.
Now starting with.

Method 1
- Navigate to the manage.py file directory and enter the following command to make a basic app in the Django project.
python manage.py startapp projectApp

You can also try this code with Online Python Compiler
Run Code
Method 2
- Navigate to the manage.py file directory and enter the following command to make a basic app in the Django project.
django-admin startapp projectApp

You can also try this code with Online Python Compiler
Run Code
This is how your directory structure will appear now.
- Consider your app in the INSTALLED_APPS list in settings.py to consider your app in your project.
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'projectApp'
]

You can also try this code with Online Python Compiler
Run Code
- So, we have finally finished building an app, but to render it using URLs, it will have to be included in our main project so that URLs redirected to it can be rendered. Let us have a look at the following steps.
Move to project name, go to url.py and add the following code in the header.
From django.urls import include

You can also try this code with Online Python Compiler
Run Code
Now specify your app name for including your app urls for that type following code -
From django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
# Enter the app name in following
# syntax for this to work
path('', include("projectApp.urls")),
]

You can also try this code with Online Python Compiler
Run Code
- In your app, to create URLs, models, views, etc., use MVT URLs to let them get automatically included in your main project.
Frequently Asked Questions
-
What files should be present for starting a project in Django?
mysite/, manage.py, mysite/urls.py, mysite/settings.py, and many more.
-
For checking the outer mysite directory, what command should we run?
py manage.py runserver
Key Takeaways
In this blog, we learned how to create an app in Django, methods we can follow, and the pre-installed apps that Django provides.
Don't come to a halt here. Check out our What is Machine Learning. You can also check out the blog on Data Science VS Artificial Intelligence VS Machine Learning VS Deep Learning.