I’m a complete noob with Django and have been googling for a while but I can’t figure out what a portion of this template is doing.
https://github.com/oppian/oppian/blob/master/oppianproj/templates/about.html
{% load set_vars_from_json %}
{% set_vars_from_json_block %}
{ "menu":
[{"name":"About", "url":"{% url about %}"},
{"name":"People", "url":"{% url people %}"},
{"name":"Labs", "url":"{% url labs %}"},
{"name":"Blog", "url":"{% url blog %}"},
{"name":"Contact", "url":"{% url contact %}"}
]}
{% end_set_vars_from_json_block %}
Why does the developer, load and set variables from a json_block? What advantage does this provide? My guess is that the menu urls are dynamically changed?
Simple Side Question:
For site content, such as the information within
<p>....</p>
, does this belong in templates or should I handle this as static data using a module?
EDIT: Or for the side question, do I just create a model for each page if I intend to store large paragraphs of static data?
Refer to the following URL
set_vars_from_json_blockis a template tagThis loads the json snippet, and in the templatetag, it parses for
end_set_vars_from_json_blockto make it a block based implementation.You could just have one model to save all by specifying “type”. Check out Django Picklefield