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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:59:00+00:00 2026-06-12T02:59:00+00:00

I have another problem. How to fix it? I am a beginner in Django.

  • 0

I have another problem. How to fix it? I am a beginner in Django.

My error:

AttributeError at /magazines/
‘Magazine’ object has no attribute ‘items_set’

class Item(models.Model):
    name = models.CharField(max_length=50)
    item_price = models.DecimalField(max_digits=5, decimal_places=2)

class Magazine(models.Model):
    items = models.ManyToManyField('Item', blank=True, null=True)
    owner = models.ForeignKey(User, related_name='u_item')  

def show(request): #magazines items and total price of all items in this magazine
        user = request.user
        magazines = Magazine.objects.filter(owner=user)

        for m in Magazine.objects.filter(owner=user):
            total = m.items_set.all().annotate(total=Sum('item_price'))
            print 'Total cost for items in {0} is {1}'.format(m,total)


        return render_to_response('magazines.html', {'magazines': magazines, 'total': total})
  • 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-12T02:59:01+00:00Added an answer on June 12, 2026 at 2:59 am

    Just try:

    total = m.items.all().annotate(total=Sum('item_price'))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following on from a question I posted yesterday about GUIs, I have another problem
I've been struggling with Zend_Navigation all weekend, and now I have another problem, which
I have another weird problem which I have not been able to solve in
another problem. I have already placed my Jython.jar into what my computer recognizes as
Okay, so I have another question on a prolog homework problem I am struggling
After getting a helpful answer here , I have run into yet another problem:
And another TreeView problem , should've used qt ;) I have a TreeView in
another ordered delivery problem. We have an orchestration which is bound to a send
I have a strange problem with integrating a ViewController into another ViewController . i
I have a problem with .NET assembly redirection. 3rd party assembly A references another

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.