remove query per row on search page
This commit is contained in:
parent
cbd9c1158d
commit
dd60f43182
2 changed files with 11 additions and 8 deletions
|
@ -29,11 +29,11 @@
|
||||||
<select id="forum" name="forum">
|
<select id="forum" name="forum">
|
||||||
<option value="0">{% trans "All forums" %}</option>
|
<option value="0">{% trans "All forums" %}</option>
|
||||||
{% for category in categories %}
|
{% for category in categories %}
|
||||||
<optgroup label="{{ category }}">
|
<optgroup label="{{ category }}">
|
||||||
{% for forum in category.forums.all %}
|
{% for forum in category.forums.all %}
|
||||||
<option value="{{ forum.id }}">{{ forum }}</option>
|
<option value="{{ forum.id }}">{{ forum }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</optgroup>
|
</optgroup>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
|
|
@ -143,9 +143,12 @@ def search(request, full=True):
|
||||||
template_dir = 'djangobb_forum/' if full else 'djangobb_forum/mobile/'
|
template_dir = 'djangobb_forum/' if full else 'djangobb_forum/mobile/'
|
||||||
|
|
||||||
def _render_search_form(form=None):
|
def _render_search_form(form=None):
|
||||||
return render(request, template_dir + 'search_form.html', {'categories': Category.objects.all(),
|
# TODO: remove 'in' clause from following query
|
||||||
'form': form,
|
categories_with_forums = Category.objects.prefetch_related('forums')
|
||||||
})
|
return render(request, template_dir + 'search_form.html', {
|
||||||
|
'categories': categories_with_forums,
|
||||||
|
'form': form,
|
||||||
|
})
|
||||||
|
|
||||||
if not 'action' in request.GET:
|
if not 'action' in request.GET:
|
||||||
return _render_search_form(form=PostSearchForm())
|
return _render_search_form(form=PostSearchForm())
|
||||||
|
|
Reference in a new issue