1. Temporary models in Django

    Occasionally I need to create a temporary model within a Django application.

    The most recent occasion for this was a one-off management command I was writing to import some data from a legacy system. The old database, for some reason, eschewed foreign keys in favour of char fields in a ...

    read more

    There are comments.

  2. 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.

  3. 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.

« Page 2 / 3 »

social