Other articles


  1. Django patterns, part 4: forwards generic relations

    My last post talked about how to follow reverse generic relations efficiently. However, there's a further potential inefficiency in using generic relations, and that's the forward relationship.

    If once again we take the example of an Asset model with a GenericForeignKey used to point at Articles and Galleries ...

    read more

    There are comments.

  2. Django patterns, part 2: efficient reverse lookups

    One of the main sources of unnecessary database queries in Django applications is reverse relations.

    By default, Django doesn't do anything to follow relations across models. This means that unless you're careful, any relationship can lead to extra hits on the database. For instance, assuming MyModel has a ...

    read more

    There are comments.

social