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">
|
||||
<option value="0">{% trans "All forums" %}</option>
|
||||
{% for category in categories %}
|
||||
<optgroup label="{{ category }}">
|
||||
{% for forum in category.forums.all %}
|
||||
<option value="{{ forum.id }}">{{ forum }}</option>
|
||||
{% endfor %}
|
||||
</optgroup>
|
||||
<optgroup label="{{ category }}">
|
||||
{% for forum in category.forums.all %}
|
||||
<option value="{{ forum.id }}">{{ forum }}</option>
|
||||
{% endfor %}
|
||||
</optgroup>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</label>
|
||||
|
|
|
@ -143,9 +143,12 @@ def search(request, full=True):
|
|||
template_dir = 'djangobb_forum/' if full else 'djangobb_forum/mobile/'
|
||||
|
||||
def _render_search_form(form=None):
|
||||
return render(request, template_dir + 'search_form.html', {'categories': Category.objects.all(),
|
||||
'form': form,
|
||||
})
|
||||
# TODO: remove 'in' clause from following query
|
||||
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:
|
||||
return _render_search_form(form=PostSearchForm())
|
||||
|
|
Reference in a new issue