0% found this document useful (0 votes)
3 views2 pages

P 6

Uploaded by

pdeepcse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

P 6

Uploaded by

pdeepcse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

-------------------------under templates folder-----------------------

create layout.html file


create home.html file
create aboutus.html file
create contactus.html file

------layout.html-----
<html>
<title>{% block title %} {% endblock %}</title>
<style type="text/css">
nav {background-color: lightblue; padding: 10px;}
</style>
<body>
<nav>
<a href="/home/">Home</a>\
<a href="/aboutus/">About us</a>\
<a href="/contactus/">Contact Us</a>\
</nav>
<section>
{% block content %}{% endblock %}
</section>
<footer>
<hr>
&copy; ISE, Developed by 6th sem, Inc.
</footer>
</body>
</html>

------aboutus.html-------

{% extends 'layout.html' %}
{% block title %}
About Us
{% endblock %}
{% block content %}
<h2> We are 6th sem students</h2>
{% endblock %}

------contactus.html-------
{% extends 'layout.html' %}
{% block title %}
Contact Us
{% endblock %}
{% block content %}
<h2> Reach Us: 7788990089 <br>
Address: AMC Engineering College</h2>
{% endblock %}

-------home.html------
{% extends 'layout.html' %}
{% block title %}
Home
{% endblock %}
{% block content %}
<h2> This is the home page</h2>
{% endblock %}
------views.py-------
from django.shortcuts import render
from django.http import HttpResponse
from django.template import context, Template

def home(request):
return render(request, 'home.html')

def aboutus(request):
return render(request, 'aboutus.html')

def contactus(request):
return render(request, 'contactus.html')

-------urls.py-------
from django.contrib import admin
from django.urls import path, include
from app6.views import aboutus, home, contactus

urlpatterns = [
path('admin/', admin.site.urls),
path('aboutus/', aboutus),
path('home/', home),
path('contactus/', contactus),
]

---------set the templates path in settings.py file------


import os
'DIRS':[os.path.join(BASE_DIR, 'templates)],
INSTALLED_APP:appname(your app name)

You might also like