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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:25:35+00:00 2026-06-02T01:25:35+00:00

The following is my model: I have two tables match and team : class

  • 0

The following is my model:

I have two tables match and team:

class Match(DictModel):
    date_time = db.DateTimeProperty()
    team1 = db.StringProperty()
    team2 = db.StringProperty()
    venue = db.StringProperty()
    result = db.IntegerProperty()

class Team(DictModel):
    tslug = db.StringProperty()
    name = db.StringProperty()
    matches_played = db.IntegerProperty()
    matches_won = db.IntegerProperty()
    rating = db.FloatProperty()

At runtime, when a post request is made to one of the handler functions, i want to dynamically associate a team rating with the queryset of Match and send the value, this is how i try to do:

matches = Match.all()
      matches.filter('date_time <=', end)
      matches.filter('date_time >=', start)
      match_dict = functs.create_dict(matches)
      self.response.out.write(match_dict)

and i have a custom function to get fetch the rating from the current team, it is as follows:

def to_dict(self):
       return dict([(p, unicode(getattr(self, p))) for p in self.properties()])

def create_dict(matches):
  lst = []
  for m in matches:
    t1 = m.team1
    t2 = m.team2
    te1 = Team.all().filter("name =", t1).get()
    te2 = Team.all().filter("name =", t2).get()
    m.setattr('rating1', te1.rating)
    m.setattr('rating2', te2.rating)
    lst.append(m)
  data_dict = json.dumps([l.to_dict() for l in lst])
  return data_dict

Trouble: i get error in setattr in place of setattr i also tried m.rating1 = te1 and m.rating2 = te2 but even that does not seem to work. Everything else is working flawlessly.

Please help thanks!

  • 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-02T01:25:36+00:00Added an answer on June 2, 2026 at 1:25 am

    The syntax is setattr(m, ‘rating1’, te1.rating1); but this is no different from m.rating1 = te1.rating1.

    May we see the trace back?

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

Sidebar

Related Questions

hi i have to following model class Match(models.Model): Team_one = models.ForeignKey('Team', related_name='Team_one') Team_two =
I have the following two models: class Parent < ActiveRecord::Base has_one :child, dependent: :destroy
So I have the following model: public class Person { public String FirstName {
I have the following model: public class Contact { public Contact() { Name =
I have the following model: public class Tag { public int Id { get;
I have the following Model pattern: public abstract class PARENTCLASS {...} public class CHILD_A_CLASS
I have the following model structure: class Container(models.Model): pass class Generic(models.Model): name = models.CharacterField(unique=True)
I have two tables tbl_business and business_contacts of the following structure: tbl_business --- business_id
I have the following models: class Match < ActiveRecord::Base has_and_belongs_to_many :teams end And class
I have two tables that look like following: RELEASE TABLE name asin MATCHES TABLE

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.