title: How do I get the request argument from django-filters.FilterList
body: <p>I'm still struggling with django-filter.  I have my filter defined below</p>
  
  <pre><code>class MasterListFilter(django_filters.FilterSet):
      project = django_filters.ModelChoiceFilter(
          label='Projects',
          name='project_fkey',
          queryset=Project.objects.filter(deleted__isnull=True)
          )
  
      class Meta:
          model = Task
          fields = ['project']
  
      @property
      def qs(self):
          parent = super(MasterListFilter, self).qs
          user = get_current_user()        
          return parent.filter(master=True, deleted__isnull=True, user_fkey=user.id)  
  </code></pre>
  
  <p>This works perfectly fine. However I also want to filter the dropdown filter (ie the Project queryset) by the current user. As my user is logged in and authenticated, I believe the user details should be attached to the request.</p>
  
  <p>According to the django-filter docs </p>
  
  <blockquote>
    <p>The FilterSet may be initialized with an optional request argument. If
    a request object is passed, then you may access the request during
    filtering. This allows you to filter by properties on the request,
    such as the currently logged-in user or the Accepts-Languages header.</p>
  </blockquote>
  
  <p>So it would seem that the request is there, but I can't work out how to access it as an argument of the FilterSet, nor have I been able to find any examples in the docs or anywhere else in my travels as to how to do it.  So if anyone can give me any clues at all, I really would appreciate the help.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Thanks Willem for the information and advice.  Very much appreciated.  However I think I may not have explained myself clearly.  The problem is not filtering the qs</p>
  
  <pre><code>@property
      def qs(self):
          parent = super(MasterListFilter, self).qs
          user = get_current_user()        
          return parent.filter(master=True, deleted__isnull=True, user_fkey=user.id)
  </code></pre>
  
  <p>this bit works fine although I will change it to use the self.request.user as suggested along with capturing any requests that are None.  This portion returns my results table that gets rendered in my hmtl page. In this case it is a list of tasks that belong to various projects. What I want to be able to do is give the users a dropdown list at the top of the page which has a list of projects that they can choose from and thereby filter the results table by individual projects. (Projects being the parent model.)  This part of the code:</p>
  
  <pre><code>class MasterListFilter(django_filters.FilterSet):
      project = django_filters.ModelChoiceFilter(
          label='Projects',
          name='project_fkey',
          queryset=Project.objects.filter(deleted__isnull=True)
          )
  </code></pre>
  
  <p>does achieve this to a point in that it gives a list of all projects that have, in this case, not been deleted.  Unfortunately the users are able to create their own projects, each of which has a foreign key back to the user who created it. Therefore, in addition to displaying projects that have not been deleted, I also want to show only the projects that belong to the current user.</p>
  
  <p>No doubt I am missing something here, but my understanding is that django_filters.FilterSet has the request as a property, but if I try to use 'user = self.request.user' in this part of the class, I get an error saying self is not defined (and looking at it, it clearly isn't.)  Frankly I'm now a bit stumped and really need some advice on this part of the code.</p>