title: How to create django-filter custom filter for month/year for a dateField in model?
body: <p>I am trying to filter date based on its month and year. Below is what I tried. In models.py</p>
  
  <pre><code>class Expense(TimeStampedModel):date = models.DateField(_('date')
  </code></pre>
  
  <p>in serailizer.py</p>
  
  <pre><code>class ExpenseSerializer(serializers.ModelSerializer):
      class Meta:
          model = Expense
          fields = '__all__'
  </code></pre>
  
  <p>in filters.py</p>
  
  <pre><code>class ExpenseFilter(django_filters.FilterSet):
      date__month = django_filters.DateFilter(field_name='date',                  
      lookup_expr='month')
      date__year = django_filters.DateFilter(field_name='date', lookup_expr='year')
      class Meta:
          model = Expense
          fields = ('date__month', 'date__year')
  </code></pre>
  
  <p>In views.py</p>
  
  <pre><code>class ExpenseViewSet(viewsets.ModelViewSet):
      queryset = Expense.objects.all()
      serializer_class = ExpenseSerializer
      filter_class = ExpenseFilter
  </code></pre>
  
  <p>When I try to hit <a href="http://127.0.0.1:8000/expense/?date__year=2019" rel="nofollow noreferrer">http://127.0.0.1:8000/expense/?date__year=2019</a> I get an empty result. Any help on this will be really appreciated.</p>