> Instances of Place will be stored in one table, and instances
> of Restaurant will be stored in another table. How would I go
> about implementing an efficient 'extent' query: a QuerySet
> which would give me an instance of Place for each row in
> **both** tables? (Or instances of Place or Restaurant as
> appropriate, but all in one query set.)

 >>> from bennett.james.caveats.subclassing import is_wise
 >>> print is_wise
False

That said... ;)

Would something like the following work for you?

   places = Place.objects.filter(...)
   restaurants = Restaurants.objects.filter(...)
   all_places = itertools.chain(places, restaurants)
   for place in all_places:
     do_something(place)

There's some duplication of the filter(...) code, which one could 
unify into something like

   f = {'category': 42, 'city__icontains': 'burg'}
   places = Place.objects.filter(**f)
   restaurants = Restaurants.objects.filter(**f)
   all_places = itertools.chain(places, restaurants)

to filter both as if you had done

   ...filter(category=42, city_icontains='burg')

on both datasets.

Just an idea,

-tkc






--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to