Monday, March 8, 2021

django day4 first app running

your app urls.py ===================== from django.contrib import admin from django.urls import path,include from . import views urlpatterns = [ path('',views.home,name="home"), path('contact',views.contact,name="contact") ] your app views.py ====================== from django.shortcuts import render from django.http import HttpResponse # Create your views here. def home(request): #1+2 #HttpResponse("

this is homepage

") #return HttpResponse("

this is test2 app homepage

") return render(request, "home.html", {'name': "the king"}) def contact(request): return HttpResponse("

this is app contactpage

") template--home.html ========================

this is templates page home page{{name}}

this is templates page home page{{name}}

this is templates page home page{{name}}

this is templates page home page{{name}}

this is templates page home page{{name}}

this is templates page home page{{name}}

project urls.py ============================= from django.contrib import admin from django.urls import path,include from . import views urlpatterns = [ path('',include('test2.urls')), path('admin/', admin.site.urls), ]

No comments:

Post a Comment

python class topic video