An app needs to be created for our Django project, which will contain the logic for the CRUD operations.
An app in Django can be created by typing the following command in the root directory of our project :
python manage.py startapp notesapp
After an app is created, it needs to be added inside the INSTALLED_APPS
key in the projects settings.py
file.
In our case, we should edit the Notes/settings.py
file as follows :
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'notesapp',
]
Now, we shall create a urls.py file and link it with the project's urls.py file.
A urls.py file should be created inside the notesapp folder.
This initial code may be added inside our notesapp/urls.py
file :
from django.urls import path
urlpatterns = [
]
Further routes for all our CRUD operation will be added inside this file.
And our project's urls.py
file should contain a link to it.
The Notes/urls.py
file should be edited as follows :
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('notesapp.urls')),
]