- only try these if you are not struggling with the more basic patterns you first learn in django
- giving routes a name can help with readability and if the URL ever changes, since everywhere that the route is referenced it is referenced by name instead of by the URL, you only have to update the URL in the one place
- Splitting views is useful when you have more than one model, e.g.,
User
andTask
and you want to have a route for all users and a route for all tasks, you can't have the two view functions with the name 'all' and two html files named 'all' unless they are split into separate view files and separate template sub-folders
- implemented in same way as multiple views
include
is used to include all the HTML from another file, can be used for re-usable or just separating out a distinct section of HTML to keep things from getting bloated- Django Girls base.html tutorial
- create a block in the head of the
base.html
that you can use to inject stylesheet<link>
tags into from other html files- e.g., your extension html file has it's own personal stylesheet that you need the
base.html
to load
- e.g., your extension html file has it's own personal stylesheet that you need the
- create a block in between the
<title>
if you want each page to be able to set the<title>
of the html page
- move all the logic that relates to the model onto the model itself to keep that separate from the views (separation of concerns)