# Let Django validate the lookup by asking it to build\r
# the final query; the way to do this has changed in \r
# Django 1.2, and we try to support both versions.\r
- _temp = self.queryset.order_by(lookup)\r
+ _temp = self.queryset.order_by(lookup).query\r
if hasattr(_temp, 'as_sql'):\r
- _temp.query.as_sql()\r
+ _temp.as_sql()\r
else:\r
from django.db import DEFAULT_DB_ALIAS\r
- _temp.query.get_compiler(DEFAULT_DB_ALIAS).as_sql()\r
+ _temp.get_compiler(DEFAULT_DB_ALIAS).as_sql()\r
break\r
except FieldError:\r
pass\r