Locked lesson.
About this lesson
To create a web page with Django, there are three important pieces: the view, the template file, and the URL. In this video, we'll cover views and how to create them.
Exercise files
Download this lesson’s related exercise files.
Django Views.docx57.1 KB Django Views - Solution.docx
57.6 KB
Quick reference
Django Views
To create a webpage with Django, we need three things: a view, a template file, and a URL.
When to use
Whenever you want to create a webpage, you'll need to create a view for it.
Instructions
To create a home view in the views.py file:
def home(request):
return render(request, ‘home.html’, {})
Hints & tips
- Webpage views go in the views.py file
- Remember that python is tab sensitive (don't tab with spaces! use the tab key!)
Lesson notes are only available for subscribers.