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

  • Home
  • SEARCH
  • 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 4544870
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:43:57+00:00 2026-05-21T15:43:57+00:00

Once i have loaded my model and filtered it if i need to, how

  • 0

Once i have loaded my model and filtered it if i need to, how do i then access the results? I can find loads of examples on querying and filtering the model but none on how to work with the object thats returned?

My model looks like this…

class Ratecard(models.Model):
    region = models.CharField(max_length=32)
    reportSuite = models.CharField(max_length=32)
    RP_UniqueUsers = models.IntegerField()
    RP_PageImpressions = models.IntegerField()
def __str__(self):
    return self.region

and my simple index view is like this…

def index(request):

    reportSuites = Ratecard.objects.all()

    return render_to_response('index.html', locals())

What i want to be able to do is filter based on region and then access the values in the other fields… This is something very simple in PHP but i know hardly any python / django so any help would be amazing.

Right, so what i need to do is perform some calculations on what is returned, so i could do… reportSuite = Ratecard.objects.get(region="Liverpool") answer = reportSuite.RP_UniqueUsers * 100

Is that correct?

  • 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-05-21T15:43:58+00:00Added an answer on May 21, 2026 at 3:43 pm

    If you wish to use instance, something like:

    reportSuite = Ratecard.objects.get(id=??)
    reportSuite.region
    
    reportSuite = Ratecard.objects.all()
    for reportSuite in reportSuites:
        reportSuite.region
    

    But if you wish to use the instance(es) in your page directly, you must do it in the template

    return render_to_response('template_name', {'reports':reportSuites})
    

    In the template:

    {%for report in reports%}
        {{report.region}}
    {%endfor%}
    

    Information about render_to_rsponse
    Info about Django Templates

    UPDATE: yes, you can do it, but best place for such things are your view functions… So:

    answer = reportSuite.RP_UniqueUsers * 100
    return render_to_response('template_link', {'reports':reportSuites, 'ans':answer})
    

    And in your tepmlate, you can use

    {{ans}}
    

    to show your result…

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

Sidebar

Related Questions

I'm trying to have images fade in with css3 once they're loaded. The problem
I need to reference a model's self in a :has_many declaration. I have a
I have a django model in use on a production application and I need
I have a JTable which is loaded from a data-structure using table model.The data-structure
I have a page with a list of items initially loaded from a include_once('show_calendarV2.php');
I once have noticied when my Adobe Reader was updating, I saw a small
Once you have your first set of requirements and design done where do you
Once you have uploaded your source code to Heroku, is it possible to download
Once I have programmed GUI with Java and have used Form Layouts. Form layout
I have once again fleshed out Ruby, after two years of not touching it,

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.