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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:01:42+00:00 2026-05-17T17:01:42+00:00

If I have the following models in a Python (+ Django) App Engine app:

  • 0

If I have the following models in a Python (+ Django) App Engine app:

class Album(db.Model):
  private = db.BooleanProperty()
  ...

class Photo(db.Model):
  album = db.ReferenceProperty(Album)
  title = db.StringProperty()

…how can I retrieve all Photos that belong to a public Album (that is, an Album with private == False)?

To further explain my intention, I thought it would be:

public_photos = Photos.all().filter('album.private = ', False)

and then I could do something like:

photos_for_homepage = public_photos.fetch(30)

but the query does not match anything, which tells me I’m going down the wrong path.

  • 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-17T17:01:42+00:00Added an answer on May 17, 2026 at 5:01 pm

    You can’t. App engine doesn’t support joins.

    One approach is to implement the join manually. For example you could fetch all photos, then filter out the private ones in code. Or fetch all public albums, and then fetch each of their photos. It depends on your data as to whether this will perform okay or not.

    The alternative approach is to denormalize your data. Put another field in the Photo model, eg:

    class Photo(db.Model): 
      album = db.ReferenceProperty(Album) 
      album_private = db.BooleanProperty()
      title = db.StringProperty() 
    

    Then you can filter for public photos with:

    public_photos = Photos.all().filter('album_private = ', False)
    

    This improves query performance, but at the expense of write performance. You will need to keep the album_private field of the photos updated whenever you change the private flag of the album. It depends on your data and read/write patterns as to whether this will be better or worse.

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

Sidebar

Related Questions

I have the following 2 models in my Google App Engine datastore: class Search(db.Model):
I have following models setup in my Django application class School(models.Model): name = models.TextField()
Lets say we have following models. class User(db.Model): username=db.StringProperty() avatar=db.ReferenceProperty() class User(db.Model): username=db.StringProperty() avatar=db.StringProperty()
Suppose I have the following Event model: from django.db import models import datetime class
I have the following model in Django: class Bout (models.Model): fighter_1 = models.ForeignKey(Fighter, related_name=bout_fighter_1)
I have the following model. from django.db import models class Client(models.Model): postcode = models.CharField(max_length=10)
(Django 1.x, Python 2.6.x) I have models to the tune of: class Animal(models.Model): pass
I have the following models: class ProjectUser(models.Model): categories = models.ManyToManyField('UserCategory', blank=True, null=True) user_id =
I have the following models class Person(models.Model): name = models.CharField(max_length=100) class Employee(Person): job =
I have the following python code: from django.db import models from datetime import datetime

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.