def shop_detail(request, name, seccion=None): shop = get_object_or_404(Shop, name=name) user = get_object_or_404(User, username=shop.user.username) print user.get_profile() # User.objects.get(username=username) if seccion: items = Item.objects.filter( image__default=True, shop=shop, shopSeccion__name=seccion).order_by('-creation_date')[:16] else: items = Item.objects.filter(image__default=True, shop=shop).order_by('-creation_date')[:16] paginator = Paginator(items, 16) # Show 25 contacts per page try: page = request.GET.get('page', 1) except PageNotAnInteger: page = 1 try: items_list = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. items_list = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. items_list = paginator.page(paginator.num_pages) items_featured_list = Item.objects.filter( image__default=True, shop=shop, featured=True).order_by('-creation_date')[:4] seccions = ShopSeccion.objects.filter(shop=shop) return render_to_response('aldrovanda/shops/detail.html', { 'user': user, 'items_list': items_list, 'items_featured_list': items_featured_list, 'shop': shop, 'shop_seccion': seccions, 'current_path': request.get_full_path() }, context_instance=RequestContext(request))
def shop_detail(request, name, seccion=None): shop = get_object_or_404(Shop, name=name) user = get_object_or_404(User, username=shop.user.username) print user.get_profile() # User.objects.get(username=username) if seccion: items = Item.objects.filter(image__default = True, shop=shop, shopSeccion__name=seccion).order_by('-creation_date')[:16] else: items = Item.objects.filter(image__default = True, shop=shop).order_by('-creation_date')[:16] paginator = Paginator(items, 16) # Show 25 contacts per page try: page = request.GET.get('page', 1) except PageNotAnInteger: page = 1 try: items_list = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. items_list = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. items_list = paginator.page(paginator.num_pages) items_featured_list = Item.objects.filter(image__default = True, shop=shop, featured=True).order_by('-creation_date')[:4] seccions = ShopSeccion.objects.filter(shop = shop) return render_to_response('aldrovanda/shops/detail.html', { 'user':user, 'items_list' : items_list, 'items_featured_list' : items_featured_list, 'shop' : shop, 'shop_seccion' : seccions, 'current_path': request.get_full_path() }, context_instance=RequestContext(request))