Creating a template tag to load a QuerySet in a template

Generally, the content that should be shown on a web page will be defined in the context by views. If the content is to be shown on every page, it is logical to create a context processor to make it available globally. Another situation is when you need to show additional content such as the latest news or a random quote on some pages, for example, the starting page or the details page of an object. In this case, you can load the necessary content with a custom {% load_objects %} template tag, which we will implement in this recipe.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.221.129.19