You are on page 1of 2

Web framework practical assignment -17

Design a Django application that adds web pages with views and templates.

Views.py

from django.shortcuts import render

# Create your views here.
def learn_dj(request):
    course_name='python'
    duration='5 weeks'
    fees='5000|-'
    details={'nm':course_name,'du':duration,'fs':fees}
    return render(request,'course1.html',details)

templates->course.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
<h1> Course:{{nm}}</h1>
<h1> duration:{{du}}</h1>
<h1> fees:{{fs}}</h1>
    
</body>
</html>

Urls.py

from django.urls import path
from . import views
urlpatterns = [
    path('learndj/',views.learn_dj)
]

Main urls.py

from django.contrib import admin
from django.urls import path,include
urlpatterns = [
    path('admin/', admin.site.urls),
    path('course/',include('course.urls'))
]

You might also like