What exactly is the behavior you are seeing? From first glance, it looks ok but I'm not exactly sure what the reporting_tools.filter is.
Are you just getting an empty queryset or is it not returning the data you expect? -Chris On Sat, Apr 3, 2010 at 9:48 AM, ManofPhysics <[email protected]>wrote: > hi, could someone explain why can't get the product in the db. > > here is my views.py: > > from django.contrib.admin.views.decorators import > staff_member_required > from django.contrib.sites.models import Site > from django.db.models import Avg, Sum > from django.shortcuts import render_to_response > from django.template import RequestContext > from reporting_tools.filters import OrderFilterSet, ProductFilterSet > from satchmo_store.shop.models import Order, OrderItem > from product.models import Product > > @staff_member_required > def orders_report(request, template='admin/reports/ > orders_report.html'): > f = OrderFilterSet(request.GET, queryset=Order.objects.all()) > sales_total = f.qs.aggregate(order_total=Sum('total')) > ctx = {'f':f, 'sales_total':sales_total } > return render_to_response(template, RequestContext(request, ctx)) > @staff_member_required > def products_report(request, template='admin/reports/ > products_report.html'): > product_list = ProductFilterSet(request.GET, > queryset=Product.objects.by_site().filter()) > ctx = RequestContext(request, {'product_list':product_list}) > return render_to_response(template, context_instance=ctx) > > here is my urls.py: > > from django.conf.urls.defaults import * > > urlpatterns = patterns('', > url(r'^orders_report/$', 'reporting_tools.views.orders_report', > name='orders_report'), > url(r'^products_report/$', > 'reporting_tools.views.products_report', name='products_report'), > ) > > and there is my templates: > > {% block content %} > <div id="content-main"> > <form action="" method="get"> > </form> > > <table id="sales" class="display"> > <thead> > <tr> > <th>Name</th> > <th>Items in Stock</th> > <th>weight</th> > <th>length</th> > <th>width</th> > <th>height</th> > <th>price</th> > </tr> > </thead> > <tbody> > {% for pppp in product_list %} > <tr> > <td>{{ ppp.name }}</td> > <td>{{ ppp.items_in_stock|floatformat }}</td> > <td>{{ ppp.weight|floatformat }} > {{ ppp.weight_units }}</td> > <td>{{ ppp.length|floatformat }} > {{ ppp.length_units }}</td> > <td>{{ ppp.width|floatformat }} > {{ ppp.width_units }}</td> > <td>{{ ppp.height|floatformat }} > {{ ppp.height_units }}</td> > <td>{{ ppp.unit_price|floatformat:"2" }}</td> > </tr> > {% endfor %} > </tbody> > </table> > </div> > {% endblock %} > > > When I visit products_report page, I can't get any product in > product_list. > > -- > 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]<satchmo-users%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/satchmo-users?hl=en. > > -- 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.
