I'm trying loop over a query set in the example.html template of the
simple project demo but I'm getting a "Caught an exception while
rendering: 'function' object is not iterable" error and don't
understand why. I ran type to make sure I'm returning a QuerySet
object which I am: <class 'django.db.models.query.QuerySet'>.
simple/localsite/models.py
from listeners import veto_for_non_members
from satchmo_store.shop import signals
from django.core.signals import request_finished
from utils import my_callback
signals.satchmo_cart_add_verify.connect(veto_for_non_members,
sender=None)
request_finished.connect(my_callback, sender=None)
simple/localsite/utils.py
def my_callback(sender, **kwargs):
user = threadlocals.get_current_user()
user = user.username
user_products = ProductAttribute.objects.filter(value__exact=user)
print type(user_products)
simple/localsite/views.py
from utils import my_callback
def example(request):
user_products = my_callback
ctx = RequestContext(request, {'user_products' : user_products })
return render_to_response('localsite/example.html', ctx)
simple/templates/localsite/example.html
{% extends "shop/base.html" %}
{% load thumbnail %}
{% block content %}
{% for product in user_products %}
<div class = "productImage">
{% if product.main_image %}
<center>
{% thumbnail product.main_image.picture 85x85 as image %}
<a href="{{ product.get_absolute_url }}"><img
src="{{ image }}" width="{{ image.width }}"
height="{{ image.height }}" /></a>
</center>
{% endif %}
<p><a href="{{ product.get_absolute_url }}">
{{ product.translated_name }}</a></p>
</div>
{% endfor %}
{% endblock %}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Satchmo users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/satchmo-users?hl=en
-~----------~----~----~----~------~----~------~--~---