无法将关键字“i”解析为字段

时间:2014-03-07 00:45:53

标签: jquery python html django mako

我正在尝试进行产品搜索,并遇到此错误

FieldError at /Catalog/search/
Cannot resolve keyword 'i' into field. Choices are: SKU, active, averageCost, category, commissionRate, description, id, image, manufacture, productName, rentalproduct, salePrice

我不知道这个'我'位于何处或如何解决问题。有人可以帮助我。

search.py​​

from django import forms
    from django.conf import settings
    from django.http import HttpResponse, HttpResponseRedirect, Http404
    from ManagerApp import models as pmod
    from . import templater
    def process_request(request):
      '''Shows list of products'''
      text = request.REQUEST.get('text')

  inventory = pmod.Product.objects.exclude(active = False).filter(productName__contains=text)

  tvars = {
    'inventory': inventory,
  }
  return templater.render_to_response(request, 'search.html', tvars)

search.html

<%inherit file="base.htm" />

  <link rel="stylesheet" href="/static/homepage/styles/.css"/>

<%block name="main_content">
<h1><div align="center">Welcome to the Homepage</div></h1>

<table class="table table-striped" border="3">
    <thead>
      <tr>
        <th><h4>Name</h4></th>
        <th><h4>Category</h4></th>
        <th><h4>Sale Price</h4></th>
        <th><h4>Picture</h4></th>
      </tr>
    </thead>
    <tbody>
        %for q in inventory:
        <tr>
          <td> ${ q.productName } </td>
          <td> ${ q.category } </td>
          <td> ${ q.salePrice } </td>
          <td> <a href='/homepage/test/'><img width='200px' src='${STATIC_URL}homepage/images/${ q.image }/' </img> </a> </td>
        </tr>
        %endfor
    </tbody>
</table>

</%block>

<%block name="right_side">

</%block>


<!--<%inherit file="base.htm" />

  <link rel="stylesheet" href="/static/homepage/styles/.css"/>

<%block name="main_content">
<div class="row">

%for q in inventory:
    <div class="col-sm-6 col-md-4">
        <div class="thumbnail">
            <img style="width: 300px; height: 200px;" src="/static/Catalog/images/${ q.image }" alt="300x200">
            <div class="caption">
                <h3>${ q.manufacture }</h3>
                <p>${ q.description }</p>
                <p> <a href="/Catalog/add_to_cart/${ q.id }" class="btn btn-primary" role="button">Add to Cart</a> <a href="/Catalog/detail/${ q.id }" class="btn btn-default" role="button">View Details</a></p>
            </div>
        </div>
    </div>
%endfor

</%block>

<%block name="right_side">

</%block>-->

0 个答案:

没有答案