andrewebdev/django-adzone — pull request #19 by melinath (2013-06-25 01:35:16+00:00)
Title: Reduce number of queries required per adzone tag.

Right now, using ``{% random_zone_ad %}`` or ``{% random_category_ad %}`` adds three queries to the page: one for the AdBase instance, one to check whether a TextAd instance exists, and one to check whether a BannerAd instance exists.

By adding a .select_related() call to AdManager.get_random_ad(), we can reduce the number of queries down to one.