From: Michael Elsdoerfer Date: Fri, 8 Jan 2010 23:17:50 +0000 (+0100) Subject: Hardly unexpected, r49 worked with the Django trunk, but caused issues with older... X-Git-Tag: 0.2~29^2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=43184b7c76a94f4e6ee148ee9f6c4d4fc648dc78;p=django-tables2.git Hardly unexpected, r49 worked with the Django trunk, but caused issues with older versions. Now both should work. --- diff --git a/django_tables/models.py b/django_tables/models.py index cfd1d48..3650edd 100644 --- a/django_tables/models.py +++ b/django_tables/models.py @@ -123,12 +123,12 @@ class BaseModelTable(BaseTable): # Let Django validate the lookup by asking it to build # the final query; the way to do this has changed in # Django 1.2, and we try to support both versions. - _temp = self.queryset.order_by(lookup) + _temp = self.queryset.order_by(lookup).query if hasattr(_temp, 'as_sql'): - _temp.query.as_sql() + _temp.as_sql() else: from django.db import DEFAULT_DB_ALIAS - _temp.query.get_compiler(DEFAULT_DB_ALIAS).as_sql() + _temp.get_compiler(DEFAULT_DB_ALIAS).as_sql() break except FieldError: pass