Yes, that's a common one. I just added something to the lecture notes
Sure. Templating puts some of your text in a file. The static parts. If you want to add content dynamically, you have to render more data to the template, and the template has to be ready for it. You could always do:
and render anything you want in your template.
Templating is mostly for structure and for "boilerplate" content, like logos, copyrights, etc. Stuff that you want on every page but is not dynamic.
To add content to a template, you have to edit the file. Because it's static.
yes, we'll see some examples today.
Flash is an easy way to have a general "messages" part of a response, for errors, updates, etc. It also has the cool ability of surviving a redirect.
You misread that. For flash()
the second is optional, but the first is required. You have to say something.
I think once you have categories, you'll probably always want to use them. Categories are a new feature; you don't have to use them, though you can distinguish, say, errors from updates.
get_flashed_messages
is not instead
of flash
. They work together.
Imagine a jar of messages. flash()
puts something in the jar.
get_flashed_messages
takes them out of the jar.
We use flash()
in our Python code to put things in the jar.
We use get_flashed_messages()
in
our templates to display the message on the page (and remove
them from the jar so that we don't display them more than once.