diff --git a/djangobb_forum/templates/djangobb_forum/search_form.html b/djangobb_forum/templates/djangobb_forum/search_form.html index 9837adb..02b3f6d 100644 --- a/djangobb_forum/templates/djangobb_forum/search_form.html +++ b/djangobb_forum/templates/djangobb_forum/search_form.html @@ -29,11 +29,11 @@ diff --git a/djangobb_forum/views.py b/djangobb_forum/views.py index f0decf4..5b02aa2 100644 --- a/djangobb_forum/views.py +++ b/djangobb_forum/views.py @@ -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())