Django LFS - custom views
Posted
by owca
on Stack Overflow
See other posts from Stack Overflow
or by owca
Published on 2010-03-09T09:44:37Z
Indexed on
2010/03/09
10:36 UTC
Read the original article
Hit count: 373
For all those ligthning fast shop users. I'm trying to implement my own first page view that will list all products from shop ( under '/' address). So I have a template :
{% extends "lfs/shop/shop_base.html" %}
{% block content %}
<div id="najnowsze_produkty">
<ul>
{% for obj in objects %}
<li>
{{ obj.name }}
</li>
{% endfor %}
</ul>
</div>
{% endblock %}
and then I've edited main shop view :
from lfs.catalog.models import Category
from lfs.catalog.models import Product
def shop_view(request, template_name="lfs/shop/shop.html"):
products = Product.objects.all()
shop = lfs_get_object_or_404(Shop, pk=1)
return render_to_response(template_name, RequestContext(request, {
"shop" : shop, "products" : products
}))
but it just shows nothing. When I do Product.objects.all() query in shell I get results. Any ideas what could cause the problem ? Maybe I should filter products with 'active' status only ? But I'm not sure if it can influence all objects in any way.
© Stack Overflow or respective owner