Is there a problem in django's many-to-many relationship mapper when it
comes to selecting the related fields? In this simple example I have a
user with permissions and they are related via an intermediary table.
"select_related()" only brings back the User object and each access of
a Permission object results in a query.
Is there a way to avoid making N queries to the database where N is the
number of users that I have?
Example Model and ORM Call:
class App(models.Model):
name = models.CharField(maxlength=32)
class Permission(models.Model):
name = models.CharField(maxlength=32)
description = models.CharField(maxlength=255)
app = models.ForeignKey(App)
class User(models.Model):
username = models.CharField(maxlength=32)
password = models.CharField(maxlength=48)
first_name = models.CharField(maxlength=50)
last_name = models.CharField(maxlength=50)
permissions = models.ManyToManyField('Permission')
user = User.objects.select_related().all()
Thanks, Trey
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---