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 8192477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:11:25+00:00 2026-06-07T04:11:25+00:00

I keep getting this error when I go to the development server that the

  • 0

I keep getting this error when I go to the development server that the ‘Tag’ object has no attribute ‘count’. I don’t understand why the error comes up in line 117 when tag.count didn’t generate any errors when used in the previous lines of code? Thanks!

Here’s the error message:

AttributeError at /tag/
'Tag' object has no attribute 'count'
Request Method: GET
Request URL:    
http://127.0.0.1:8000/tag/

Django Version: 1.4
Exception Type: AttributeError
Exception Value:    
'Tag' object has no attribute 'count'
Exception Location: /Users/jonathanschen/Python/projects/skeleton/django_bookmarks/django_bookmarks/bookmarks/views.py in tag_cloud_page, line 117
Python Executable:  /usr/bin/python
Python Version: 2.7.1
Python Path:    
['/Users/jonathanschen/Python/projects/skeleton/django_bookmarks',
 '/Library/Python/2.7/site-packages/pip-1.1-py2.7.egg',
 '/Library/Python/2.7/site-packages/distribute-0.6.27-py2.7.egg',
 '/Library/Python/2.7/site-packages/nose-1.1.2-py2.7.egg',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
 '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
 '/Library/Python/2.7/site-packages',
 '/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']
Server time:    Mon, 9 Jul 2012 11:35:33 -0500

The code it refers back to is this:

def tag_cloud_page(request):
    MAX_WEIGHT = 5
    tags = Tag.objects.order_by('name')
    # Calculate tag min and max counts
    min_count = max_count = tags[0].bookmarks.count()
    for tag in tags:
        tag.count = tag.bookmarks.count()
        if tag.count < min_count:
            min_count = tag.count
        if max_count < tag.count:
            max_count = tag.count
        #calculate count range. Avoid dividing by zero.
        range = float(max_count - min_count)
        if range == 0.0:
            range = 1.0
        # Calculate tag weights.
        for tag in tags:
            tag.weight = int(
                MAX_WEIGHT * (tag.count - min_count) / range #line 117
            )
        variables = RequestContext(request, {
            'tags': tags
        })
        return render_to_response('tag_cloud_page.html', variables)
  • 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-07T04:11:26+00:00Added an answer on June 7, 2026 at 4:11 am

    You iterate over tags twice with the same keyword tag. Turn your second for loop into something like this:

    for related_tag in tags:
    

    Also, you need to change tag.weight = ... in that second loop, so that it refers to the correct tag and related_tag instances.

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

Sidebar

Related Questions

I keep getting this error Object reference not set to an instance of an
Keep getting this error after inserting a subdatasheet into a query and trying to
I keep getting this error and have no idea why. I googled and scanned
I keep getting this error on emulator: I copied this from a tutorial and
I keep getting this error Error in readPNG(destfile) : libpng error: PLTE: CRC error
I keep getting this error with my Play 2.0 application: play.core.ActionInvoker$$anonfun$receive$1$$anon$1: Execution exception [[MatchError:
I keep getting this error when using django templates in Google App Engine: TemplateSyntaxError:
I keep getting this error in the $('#savetickets-list') line. I want to dynamically add
I keep getting this error System.Web.HttpException was unhandled by user code Message=Validation of viewstate
I keep getting this error when I try to commit a group of executed

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.