Locked lesson.
About this lesson
In this lesson, we'll discuss the purpose of the Context Dictionary and how it works with the variables you might use within your project.
Exercise files
Download this lesson’s related exercise files.
Context Dictionary.docx57.4 KB Context Dictionary - Solution.docx
57.9 KB
Quick reference
Context Dictionary
A context dictionary allows you to pass variables or any type of data from your Django backend to a web page.
When to use
Use them any time you have data on your back end (in views.py or anywhere else) that you want to pass to a web page and use on that web page.
Instructions
Context dictionaries are python dictionaries. They're composed of key/value pairs that can be passed to a web page and then accessed using a Django Template Language variable.
Hints & tips
- Context Dictionaries go in the page function of your views.py file.
- {'first_name': "John"}
- {{ first_name }}
Lesson notes are only available for subscribers.