Should entry_set be cached with select_related? My DB is still getting calls even after I use select_related. The pertinent sections
class Alias(models.Model):
achievements = models.ManyToManyField('Achievement', through='Achiever')
def points(self) :
points = 0
for a in self.achiever_set.all() :
po...
I'm trying to optimize the database calls coming from a fairly small Django app. At current I have a couple of models, Inquiry and InquiryStatus. When selecting all of the records from MySQL, I get a nice JOIN statement on the two tables, followed by many requests to the InquiryStatus table. Why is Django still making individual reque...
I have :
class Award(models.Model) :
name = models.CharField(max_length=100, db_index=True)
class Alias(models.Model) :
awards = models.ManyToManyField('Award', through='Achiever')
class Achiever(models.Model):
award = models.ForeignKey(Award)
alias = models.ForeignKey(Alias)
count = models.IntegerField(default=1)
...
I have a simple music schema: Artist, Release, Track, and Song. The first 3 are all logical constructs while the fourth (Song) is a specific instance of an (Artist, Release, Track) as an mp3, wav, ogg, whatever.
I am having trouble generating an ordered list of the Songs in the database. The catch is that both Track and Release have a...
In Django, I've got a Checkout model, which is a ticket for somebody checking out equipment. I've also got an OrganizationalUnit model that the Checkout model relates to (via ForeignKey), as the person on the checkout belongs to an OrganizationalUnit on our campus.
The OrganizationalUnit has a self relation, so several OUs can be the ch...
Imagine the following model:
class Parent(Model):
...
class Child(Model)
father = ForeignKey(Parent)
...
Some parents have children, others do not (they're not parents in the real meaning, it's just a fictional name).
I would like to make the following query: I want to list all the Parents, and if they have children, bri...
I am trying to return a django.contrib.auth.models.User object, and it fetches all the data properly, but the related fields are nowhere to be found, even utilizing "select_related()" as suggested in documentation.
class UserProfile(models.Model):
user = models.ForeignKey( User, unique=True )
In pyamf gateway:
def login_user( http_...
Take a look at this model (it's hypothetical):
class Manufacturer(models.Model):
#...
class Car(models.Model):
manufacturer = models.ForeignKey(Manufacturer)
#...
class City(models.Model):
#...
class Manager(models.Model):
manufacturer = models.ForeignKey(Manufacturer)
city = models.ForeignKey(City)
#...
...
Django doesn't support displaying of related objects from a many-to-many relation in the changelist for a good reason. It would result in a lot of database hits.
But sometimes it is inevitable and necessary to e.g. display an object's categories, which have a many-to-many relation to the object, in the changelist. Given that case, does ...