Articles

A collection of technical articles, primarily on programming.

  1. Django application import and missed class_prepared signals

    Due to opaque application loading semantics within the Django i18n code, several model classes may be imported before a class_prepared signal listener connects, resulting in missing the signal entirely. Specifically, connecting to this signal from an application which appears first in INSTALLED_APPS, does not guarantee that it will execute when a class is first imported by any of the subsequent applications.

  2. Propagating field changes in Django Model instance aliases

    Django's ORM creates multiple aliases for the same Model instance. In certain situations this may result in problematic behavior, as multiple operations on the same instance are interleaved, however, field access happens on different aliases of the instance, ultimately resulting in loss of updates.

  3. Duplicate items when ordering by Generic Relation in Django

    When the optional ordering = ... attribute of a Django Model's Meta class contains a GenericRelation from the Content Types framework, there is no way to eliminate duplicate items being returned, even when using .distinct() (since .order_by(...) is applied by the ORM only after the SQL SELECT DISTINCT clause is built)