jeudi 24 avril 2014

jQuery - ne peut pas résoudre le mot-clé « i » dans le champ - Stack Overflow


I am trying to do a product search, and ran into this error


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

I have no idea where this 'i' is located or how to fix the problem. Can someone help me out.


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>-->


I am trying to do a product search, and ran into this error


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

I have no idea where this 'i' is located or how to fix the problem. Can someone help me out.


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 commentaires:

Enregistrer un commentaire