#9394: Querying a many-to-many intermediate model from a manager on a 
multi-table
inherited model produces extraneous queries
------------------------------------------+---------------------------------
 Reporter:  ikelly                        |       Owner:  nobody    
   Status:  new                           |   Milestone:            
Component:  Database layer (models, ORM)  |     Version:  SVN       
 Keywords:                                |       Stage:  Unreviewed
Has_patch:  0                             |  
------------------------------------------+---------------------------------
 With the following models:
 {{{
 class Place(models.Model):
     name = models.CharField(max_length=50)

 class Business(Place):
     owner = models.CharField(max_length=50)

 class Restaurant(Business):
     rating = models.IntegerField()

 class Chef(models.Model):
     name = models.CharField(max_length=50)
     restaurants = models.ManyToManyField(ChineseRestaurant,
 through='Employee')

 class Employee(models.Model):
     restaurant = models.ForeignKey(ChineseRestaurant)
     chef = models.ForeignKey(Chef)
     years_of_service = models.IntegerField()
 }}}
 we can do {{{some_restaurant.employee_set.all()}}}, which results in three
 queries.  The first two queries are just retrieving the attributes of the
 inherited Business and Place models, which is unnecessary since all that
 information already exists on the some_restaurant object.  Only one query
 should be needed.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/9394>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to