When working with generic relations in Django you have to be quite careful not to end up with n+1 queries for a simple fetch of n elements. The reason for this is that internally a generic relation is not really a true foreign key (naturally) but just an id combined with a foreign key to a content-type. But there are some ways around this problem. Among them a quite simple one: Doing the actual content-loading by yourself.
Read more about "GenericForeignKeys with fewer queries" ...Archive for contenttypes
-
GenericForeignKeys with fewer queries
-
zerokspot+Django: contenttypes and permalinks
As some kind of project for the next couple of months I've now started to work on a new implementation of zerokspot.com no longer using a pre-built CMS like WordPress or Drupal but trying to do it completely on my own using Django and several generic apps for it.
Read more about "zerokspot+Django: contenttypes and permalinks" ...