9👍
✅
Start a new application known as pages
, this will actually create a directory named pages in the root of your project. Then go to the views.py
file and add something like this:
from django.shortcuts import render
from django.http import HttpResponse
# Create your views here.
def home_view(request,*args, **kwargs):
return HttpResponse("<h1>Hello World</h1>")
After this go to the main project folder under which there is a file named urls.py
.
Edit the file and change it to the following:
from django.contrib import admin
from django.urls import path
from pages.views import home_view, about_view, contact_view
from products.views import product_detail_view
urlpatterns = [
path('', home_view, name='home'),
path('home/', home_view, name='home'),
]
Then go to settings.py
and there you will find a list
named INSTALLED_APPS
. Just change the list to the following:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# own
'pages',
]
Hope this helps 🙂
Source:stackexchange.com