title: django get the logged in user in the form to build queryset?
body: <p>I have this model:</p>
  
  <pre><code>class Searches(models.Model):
      user = models.ForeignKey(User)
      .....other fields
  </code></pre>
  
  <p>Each <code>user</code> has certain saved searches. I want to display a <code>form</code>(a <code>choiceSelect widget</code>) to select one of the several searches and click go. I want to <code>filter</code> in the <code>form</code> to display only the <code>searches</code> of that particular <code>User</code>. This is what I tried. but <code>request.user</code> below does not work.  how to fix this?</p>
  
  <p>This is my form:</p>
  
  <pre><code>class SearchesForm(forms.Form):
      #get the queryset for the searches model of logged in user
      qset=Searches.objects.filter(user=request.user) ----&gt; error
      #get the most recent entry
      default=Searches.objects.latest('id')
      choices = forms.ModelChoiceField(queryset=qset,label='select search',initial=default)
  </code></pre>
  
  <p>EDIT:
  my view:</p>
  
  <pre><code>def display_search_user(request):
      form=SearchesdiffForm(request)
      if request.method=='POST':
          search=SearchesdiffForm(request,data=request.POST)
          print search
          return HttpResponse(search)
      return render(request,'search_list.html',{'form':form})
  </code></pre>