andrewebdev / django-adzone

A django application to manage advertising and advertising zones.
BSD 3-Clause "New" or "Revised" License
87 stars 39 forks source link

Specify custom queryset for AdImpressions and AdClicks to streamline select_related #28

Closed melinath closed 10 years ago

melinath commented 10 years ago

Currently, AdImpressions and AdClicks have an fk in their admin list view, which triggers select_related without any limits. That means that all related models and model fields (to an unlimited depth) will be selected - even though all that's being used is the ad name!

I'd suggest the following querysets:

AdImpression.objects.select_related('ad').only('ad__title', 'impression_date', 'source_ip')
AdClick.objects.select_related('ad').only('ad__title', 'click_date', 'source_ip')
andrewebdev commented 10 years ago

I agree fully. The app has outgrown my initial use cases more than I expected, so this kind of optimization is definitely required at some point.

I have scheduled some time to review adzone issues and features this coming weekend, and will prioritize this.