using variable inside django with django template tags for HTML code {% block accordion id=’myID’ %}

I want to send variable via django templates tags like {% block panel id='myPanelID' %} so that I don't need to write chuck of codes myself to make accordions.

<div class="accordion col-lg-6" id="DisplayStudentsClass">
  <div class="card mb-4">
    <button
      class="btn btn-link"
      type="button"
      data-toggle="collapse"
      data-target="#display_class"
      aria-expanded="true"
      aria-controls="collapseOne"
    >
      <div class="card-header" id="StudentsClass">
        <h5 class="mb-0">Create Classes</h5>
      </div>
    </button>

    <div
      id="display_class"
      class="collapse show"
      aria-labelledby="StudentsClass"
      data-parent="#DisplayStudentsClass"
    >
      <div class="card-body">
        <form method="POST" action="/settings" enctype="multipart/form-data">
          {% csrf_token %}

          <div class="form-group">
            <label for="classInput">Class or Grade</label>
            <input
              type="text"
              class="form-control"
              id="classInput"
              name="classes"
              aria-describedby="classHelp"
              placeholder="Example: Kindergarten, 1, 2, 3, etc."
            />
            <small id="classHelp" class="form-text text-muted">
              Create the class <strong><em>{{sdata.sname}}</em></strong
              >has.
            </small>
          </div>
          <button type="submit" role="button" class="btn btn-primary btn-block">
            Submit
          </button>
        </form>
      </div>
    </div>
  </div>
</div>

I want to short the upper code via django template tags. The upper code must work like this:

{% block panel_header id='myPanelID' %} Create Classes {% endblock %}
{% block panel_body id='myPanelID' %} <...BODY> {% endblock %}


Read more here: https://stackoverflow.com/questions/64392703/using-variable-inside-django-with-django-template-tags-for-html-code-block-ac

Content Attribution

This content was originally published by Bishwas Bhandari at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: