I've got a model with a few foreign keys. Normally this isn't a
problem except in one case when I create a Profile ChangeManipulator,
it results on the following query repeated once per GameOfInterest
associated with the given Profile:


'time': '0.046', 'sql': 'SELECT
"game_room_app_game"."id","game_room_app_game"."name","game_room_app_game"."genre_id"
FROM "game_room_app_game" ORDER BY "game_room_app_game"."name" ASC'


Obviously, the performance deteriorates rapidly as the number of
GamesOfInterest added to a Profile increases. Is there any way to
avoid this?

Here is the relevant portion of my model file (with some fields
removed for brevity). Essentially, I have a GameOfInterest that
associates a Profile to a Game, and a Profile can have any number of
these:

class Game( models.Model ):
    class Admin:
        pass

    class Meta:
        ordering = ( 'name', )

    def __str__( self ):
        return self.name

    name = models.CharField( maxlength=60, unique=True )
    genre = models.ForeignKey( GameGenre )


class Profile( models.Model ):
    class Admin:
        pass
        # waiting on bug #2076
        #ordering = ( 'user__username' )

    def __str__( self ):
        return self.user.username

    user = models.ForeignKey( User, unique=True,
edit_inline=models.STACKED,
                              max_num_in_admin=1, num_in_admin=1,
core=True )
)

class GameOfInterest( models.Model ):
    class Admin:
        pass

    def __str__( self ):
        return self.game.name

    game = models.ForeignKey( Game, blank=False )
    profile = models.ForeignKey( Profile, edit_inline=models.TABULAR,
num_in_admin=1, core=True, blank=False )


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to