How to do it...

To complete the recipe, follow these steps:

  1. Create IdeaFilterForm with all of the possible categories to filter by:
# myproject/apps/ideas/forms.pyfrom django import formsfrom django.utils.translation import ugettext_lazy as _from django.db import modelsfrom django.contrib.auth import get_user_modelfrom myproject.apps.categories.models import Categoryfrom .models import RATING_CHOICESUser = get_user_model()class IdeaFilterForm(forms.Form):    author = forms.ModelChoiceField(        label=_("Author"),        required=False,        queryset=User.objects.annotate(            idea_count=models.Count("authored_ideas")        ).filter(idea_count__gt=0),    )    category = forms.ModelChoiceField(        label=_("Category"),        required=False,        queryset=Category.objects.annotate(            idea_count ...

Get Django 3 Web Development Cookbook - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.