What is the best practice for filtering based on a foreign key property in a non-relational database? I understand that the lack of support joincomplicates the situation, and therefore I was wondering how others get around it.
In my case, I have events belonging to sites belonging to regions. I want to filter out all the events in this region. Eventhas a property sitethat is a foreign key for site, which, in turn, has a foreign key regionfor region:
region = Region.objects.get(id=regionID)
events = Event.objects.filter(site__region=region)
This does not work because the __region site is required joinand which is not supported in the django-nerel running in the Google App Engine. (I get it Caught DatabaseError while rendering: This query is not supported by the database.as an error.) I thus repeat the events, adding those that match the list:
events = list()
region = Region.objects.get(id=regionID)
for event in Event.object.all():
if event.site.region==region:
events.append(event)
Is this a good way to do something? Is there something stupid that I forgot? Thanks in advance!
source
share