I'm trying to return a QuerySet object from a receiver function,
inside a view, but I'm not quite sure how to do it. I get the error:
my_callback() takes exactly 1 argument (0 given) because I'm
incorrectly calling it without any args, but I'm not sure what to
supply as the sender because as shown in the example I connect to the
receiver with, for instance, request_finished.connect(my_callback).
This works as expected from the output of the the terminal but what if
I want my_callback to return a QuerySet object and I want to access
that from within a view?

localsite/models.py

from django.core.signals import request_finished
from utils import my_callback

request_finished.connect(my_callback)



localsite/utils.py

from product.models import ProductAttribute
from threaded_multihost import threadlocals

def my_callback(sender, **kwargs):
    user = threadlocals.get_current_user()
    user = user.username
    user_products = ProductAttribute.objects.filter(value__exact=user)
    return user_products



localsite/views.py

from django.shortcuts import render_to_response
from django.template import RequestContext
from utils import my_callback

def example(request):
    user_products = my_callback()
    print type(user_products)
    ctx = RequestContext(request, { 'user_products' : user_products })
    return render_to_response('localsite/example.html', ctx)
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to