QuerySet Raised: Related Field got invalid lookup: icontains
<p>Am learning Django and I used ForeignKey to link my models.
icontains work in field that are not ForeignKeys.</p>

<p>I want to filter the Items in my model to show me only fields that match the queryset.
But queryset raised: <strong>Related Field got invalid lookup: icontains</strong></p>

<p>Please help. Below is My model and View</p>

<p><strong>My Model</strong></p>

<pre><code>class Category(models.Model):
    category = models.CharField(max_length=200, default='', blank=True, null=True)
    def __unicode__(self):
        return self.category

class StoreItems(models.Model):
    item_name = models.CharField(max_length=200, default='', blank=True, null=True)
    def __unicode__(self):
        return self.item_name

class Supplier(models.Model):
    supplier_name = models.CharField(max_length=200, default='', blank=True, null=True)
    def __unicode__(self):
        return self.supplier_name

class Unit(models.Model):
    unit = models.CharField(max_length=200, default='', blank=True, null=True)
    def __unicode__(self):
        return self.unit





class Store(models.Model):
    category = models.ForeignKey(Category, blank=True, null=True)
    item_name = models.ForeignKey(StoreItems, blank=True, null=True)
    quantity = models.IntegerField(default='', blank=True, null=False)
    receive_amount = models.IntegerField(blank=True, null=True)
    receive_by = models.CharField(max_length=120, default='', blank=True, null=False)
    issue_amount = models.IntegerField(blank=True, null=True)
    issue_by = models.CharField(max_length=120, default='', blank=True, null=True)
    issue_to = models.CharField(max_length=120, default='', blank=True, null=True)
    supplier_name = models.ForeignKey(Supplier, blank=True, null=True)
    created_by = models.CharField(max_length=15, default='', blank=True, null=True)
    unit = models.ForeignKey(Unit, blank=True, null=True)
    reorder_level = models.IntegerField(default='0', blank=True, null=False)
    export_to_CSV = models.BooleanField(default=False)
    last_updated = models.DateTimeField(auto_now_add=False, auto_now=True)
</code></pre>

<p><strong>My View</strong></p>

<pre><code>def store_list(request):
    label = 'STORE'
    title = 'Select the item you want to filter'    
    heading = 'SEARCH ITEMS'

    if request.user.is_authenticated():
        form = StoreSearchForm(request.POST or None)
        context = {
        "title": title,
        "form": form,
        "heading": heading,
        }
        if request.method == 'POST':
            queryset = Store.objects.all().order_by('item_name').filter(category__icontains=form['category'].value(), item_name__icontains=form['item_name'].value())
            context = {
            "queryset": queryset,
            "form": form,
            }

    return render(request, "store.html", context)
</code></pre>