Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8297263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:20:54+00:00 2026-06-08T15:20:54+00:00

Im going through the beginning Django ecommerce book, and I am stuck on trying

  • 0

Im going through the “beginning Django ecommerce” book, and I am stuck on trying to show the “go to cart” link on all the pages.

I get this error: 'str' object has no attribute 'session' and the line

"{% cart_box request%}" in the HTML is highlighted with this error.

this is the HTML

{% load catalog_tags %}

<div class="cart_box">

    {% cart_box request %}

</div>

{% if hour == 7 or hour == 9 or hour == 12 %}   

Order time = {{hour}}

this is the view.

def menu_hour(request,hour):

    #set the test cookie
    request.session.set_test_cookie()

    hour = int(hour)
    food = Food.objects.all()
    output = ', '.join([f.name for f in food])

    steak = Food.objects.get(name="Steak and Egg Burrito")
    steak.price = 15
    steak.save()

    queso = Food.objects.get(name="Queso Burrito")
    queso.time = hour

    food_dict = {"steak": steak, "queso": queso, "hour":hour}
    return render_to_response('menu_hour.html', food_dict, context_instance=RequestContext(request))

this is the catalog tag

from django import template 
from cart import cart

register = template.Library()

@register.inclusion_tag("tags/cart_box.html") 
def cart_box(request):
    cart_item_count = cart.cart_distinct_item_count(request) 
    return {'cart_item_count': cart_item_count }

this is the catalog tag HTML

{% with cart_item_count as cart_count %} 
    <a href="{% url show_cart %}">
        Shopping Cart
        <br />
        {{ cart_count }} Item{{ cart_count|pluralize }}
    </a>
{% endwith %}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T15:20:56+00:00Added an answer on June 8, 2026 at 3:20 pm

    It’s because i wasn’t passing “request” in my dictionary to the template.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm going through the Beginning iPhone Development book & stuck in chapter 9. I've
I've been going through a beginning Python book, and I've been trying to write
I was going through htdp and found this somewhere in the beginning :- Explain
I am going through some code and at the beginning of the script we
While going through some tutorials, I have encountered lines such as this: ((IDisposable)foo).Dispose(); Ignore
I'm trying to learn SQL Service Broker (SSB), and I'm starting by going through
I'm beginning with backbone.js Going through some tutorials, like the one shown below. I
I'm trying to work through Beginning Hibernate 3.5, and I've hit an initial snag.
Going through happstack-lite tutorial : we build functions that have return type of ServerPart
Going through some of my older Delphi projects and upgrading them to D2009, as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.