Join Caleb Smith for an in-depth discussion in this video Introducing template tags, part of Up and Running with Python and Django.
- View Offline
- Templates are HTML files that have extra syntax.…When a view calls render, it passes data into the template,…and the template generates the HTML to show the user.…The syntax for Django templates has three pieces.…A variable's value is shown when the variable name is…used inside of double curly braces.…Template tag is enclosed in curly braces with…percent, and are used for for loops, ifs, structrual…elements, and some other things.…Lastly, a variable can have a pipe character…after it to use a template filter.…
Template filters take a string as input and return a string…as output, and can be thought of…much like the pipe in shell scripting.…These are mostly used to take a string and change…some formatting, such as date/time output formatting, or…just plain text in various cases, like title or uppercase.…As an example of using variables in a template,…let's assume we are editing the item_detail HTML template,…so a specific item has been passed into the template.…Here we have an h3 tag, and we use the double…
- Creating a new Django project
- Defining Django models and fields
- Querying data with the Django ORM
- Building views and templates