Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well, i think you can resolve it in view-side. I dont know your views, but I give an example:</p> <pre><code>def checklist_options(request): # I dont know how you get your query checklist_options = CheckOption.objects.all() #I dont know where it comes from is_master = True if is_master: masters_checklist_options = checklist_options.filter(is_master=True) #I dont know where it comes from is_ingest = True if is_ingest: ingest_checklist_options = checklist_options.filter(is_ingest=True) return render(request, ' main.html', { "masters_checklist_options": masters_checklist_options "ingest_checklist_options": ingest_checklist_options },) </code></pre> <p>So, your main.html can be:</p> <pre><code>&lt;div class="ingest"&gt; {% includes "checklist.html" with collection=ingest_checklist_options %} &lt;/div&gt; &lt;div class="master"&gt; {% includes "checklist.html" with collection=master_checklist_options %} &lt;/div&gt; </code></pre> <p>and checklist.html:</p> <pre><code>{% for option in collection %} do something {% endfor %} </code></pre> <p>What do you win?</p> <p>You let your login in views (it should be in models, maybe).</p> <p>You avoid the n+1 problem when you call <code>{% if option.is_master %}</code>, as an example. Because in each rendering of check_list.html, you already had filterer the <code>is_master</code> or <code>is_ingest</code> options.</p> <p>I hope you undestand my point, i've guessed you models and give you a fool view example. If you need help, show us your view and models, and i'll be able to help you more.</p> <p>Hope helps</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload