Create Pages App for the Home Page Django.How

Author avatar wrote on 26/05/2022

Create Pages App

  1. Stop the server

  2. Create an app python startapp pages

  3. In pages app create a view by editing the file

from django.shortcuts import render

def index(request):
  return render(request, 'pages/index.html')

Create URLs (Routing)

4. Create file

from django.urls import path

from . import views

urlpatterns = [
    path('', views.index, name='index'),

5. Edit the main file and add

path('', include('pages.urls')),

Create the template

6. Create the template, in templates create a folder for pages and create index.html file

7. Run the server python runserver