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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:52:47+00:00 2026-05-20T04:52:47+00:00

class Student(db.Model): teacher = db.ReferenceProperty(Teacher, collection_name=’students’) name = db.StringProperty(required=True) zip_code = db.IntegerProperty(required=True) square_footage =

  • 0
class Student(db.Model):
    teacher = db.ReferenceProperty(Teacher, collection_name='students')
    name = db.StringProperty(required=True)
    zip_code = db.IntegerProperty(required=True)
    square_footage = db.IntegerProperty(required=True)
    month_entries = db.IntegerProperty(required=True)  

class Bill(db.Model):
    student = db.ReferenceProperty(Student, collection_name='bills')
    bill_month = db.DateProperty(required=True)
    energy = db.IntegerProperty(required=True)

From my models setup shown above… I can easily show all the Bills stored using something like this:

bill = models.Bill.all()
for stubs in bill:
    print stubs.energy
    print stubs.student.name

But how do I list what Bills each student has?
In SQL I would say something like:

SELECT * FROM Bill WHERE Student.Name = Samuel

I guess I don’t understand how to retrieve the Bills given by ReferenceProperty. It doesn’t seem so simple in GQL. How do I query by Reference Property?

  • 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-20T04:52:48+00:00Added an answer on May 20, 2026 at 4:52 am

    The ReferenceProperty creates an automatic query in the referenced entity (using the collection_name if you provided one, which you did):

    sams_bills = Student.all().filter("name =", "Samuel").get().bills
    

    sams_bills is now a db.Query for the bills, which you can call .fetch() on to retrieve one or more bills.

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

Sidebar

Related Questions

Please see the following Django models: - class Student(models.Model): reference_num = models.CharField(max_length=50, unique=True) name
If you have some models: class Teacher(models.Model): name = models.CharField(max_length=50) class Student(models.Model): age =
I'm a blind student who's taking a required UI class. One of the assignments
class Tag(models.Model): name = models.CharField(maxlength=100) class Blog(models.Model): name = models.CharField(maxlength=100) tags = models.ManyToManyField(Tag) Simple
My code: class School(models.Model): pass class Student(models.Model): school = models.ForeignKey(School) TYPE_CHOICES = ( ('ug',
I have a similar model Class Student(models.Model): A simple class which holds the basic
We have a Student class in our business model. something struck me as strange,
I have a data class Student, and I have an aggregate class Students. Student
Imagine a hypothetical object with a number of attributes: pseudocode: class Student { Name:
<?php class Student { public $name = Benjamin; } $name = new Student(); ?>

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.