In this chapter, we covered the Django Context
class and its usage. This was a code-heavy chapter; don't feel bad if you need to go through the chapter again to make sure you got everything.
We saw how to instantiate the Context
object and pass its values from our views. We briefly looked at manipulating an existing context, and how to use locals()
to lazily pass all items from our current scope into the Context.
We looked at how to use these values from the context in our templates and how Django handles invalid variables. We also saw some shortcuts for rendering contexts and how to subclass Context
with the RequestContext
class to get additional items into our Context.
Next, we'll look at how to use Django's built-in tags and filters.