title: Django Filter Results
body: <p>I am a little stuck on how to perform a task, so was wondering if anyone could help.</p>
  
  <p>I have this model and model form:</p>
  
  <pre><code>class Prefabrication(models.Model):
      prefabrication_id = models.AutoField(primary_key=True)
      matlist = models.ForeignKey(MatList, blank=True, null=True)
      sizelist = models.ForeignKey(SizeList, blank=True, null=True)
      quantity = models.IntegerField(blank=True, null=True)
      workpack = models.ForeignKey(Workpack, blank=True, null=True)
      code = models.CharField(max_length=50)
      lineclass = models.ForeignKey(Lineclass, blank=True, null=True)
  
  
  class CreateNewPrefabForm(forms.ModelForm):
      class Meta:
          model = Prefabrication
          fields = ('prefabrication_id', 'matlist', 'sizelist', 
                    'quantity', 'workpack', 'lineclass')
  </code></pre>
  
  <p>This represents a form i am using to collect information from the user.</p>
  
  <p>I am trying to get a certain value from the lookup table based on the matlist, and sizelist
  values given by the user.</p>
  
  <p>I have tried using this:</p>
  
  <pre><code>if request.method == 'POST':
      if createprefabcons['newprefab'].is_valid():
          item = Lineclass.objects.filter(itemname__icontains=createprefabcons['newprefab'].cleaned_data['matlist'],
                                          dn1__icontains=createprefabcons['newprefab'].cleaned_data['sizelist'],
                                          lineclassname__icontains=createprefabcons['newprefab'].cleaned_data['matlist'])
          createprefabcons['newprefab'].cleaned_data['code'] = item
          createprefabcons['newprefab'].save()
          return HttpResponseRedirect('/')
  </code></pre>
  
  <p>with filters to try and get the code of the item returned by filtering. As far as i know there
  should only be one item returned from the filter search and that item will have a code that i wish to add after the user has given the details to search by.</p>
  
  <p>Everything saves fine into the db but the code field is blank so either i am doing something wrong or there is no value that matches, which if the filtering is done right their has to be a match. Could anyone please give some advice.</p>
  
  <p>Thanks very much.</p>