title: Django Filter Buttons
body: <p>I'm using Django-filter in a very standard way. </p>
  
  <pre><code>class TaksFilter(django_filters.FilterSet):
      class Meta:
          model = Task
          fields = ['lastUpdated']
  </code></pre>
  
  <p>But I want to create custom quick filter buttons. Like last 1 day and last 7 days which essentially run this query set. </p>
  
  <pre><code>task = Task.objects.filter(lastUpdated__range=["2016-12-09", "2016-12-10"])
  </code></pre>
  
  <p>Is this something that can be done with django-filter or do I need to create a standard POST or GET response?</p>
  
  <p><strong>Solved</strong></p>
  
  <p>Thanks Ivo Donchev for the help. Using your code I solved it like this. I didn't want to go down the route of class based views as I am using functions.</p>
  
  <p>form.py</p>
  
  <pre><code>class TaskFilter(django_filters.FilterSet):
  last_updated = django_filters.MethodFilter()
  
  class Meta:
      model = Task
      fields = ['lastUpdated']
  
  def filter_last_updated(self, value, queryset):
          qs = queryset.filter(lastUpdated__gte=datetime.now()-timedelta(days=value))
          return qs    
  </code></pre>
  
  <p>view.py</p>
  
  <pre><code>def tasks(request):
  
      tasks = TaskFilter(request.GET, queryset=Task.objects.all())
  
      if request.method == "GET":    
  
          if '1' in request.GET:
  
              value = 1
              tasks = TaskFilter(request.GET, queryset=(TaskFilter.filter_last_updated(tasks, value, queryset=(Task.objects.all()))))
  
      context = {
      'tasks':tasks,
      }
  
  return render(request, 'tasks.html', context)
  </code></pre>
  
  <p>I know I can streamline the view a little. Next task.</p>