Line 125 of models.py throws an exception with the latest Django trunk

Bug #503652 reported by Zeth
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
django-tables
Fix Committed
Undecided
Unassigned

Bug Description

Hello line 125 of: django_tables/models.py

_temp.query.as_sql()

The .as_sql method is gone from the Django trunk, therefore when you using django-tables you get:

'Query' object has no attribute 'as_sql'

Deleting the line stops the error, but obviously breaks whatever this line was trying to do.

Revision history for this message
Zeth (zeth0) wrote :

An equivalent would be _temp.query.__str__() but I do not know if that would have whatever side-effect you need to throw the exception. Surely there is a more direct way of doing whatever you are trying to do?

Anyhow, this is what I used.

                try:
                    # let django validate the lookup
                    _temp = self.queryset.order_by(lookup)
                    _temp.query.__str__()
                except FieldError:
                    pass
                else:
                    break

Revision history for this message
Michael Elsdörfer (miracle2k) wrote :

Thanks, just committed the fix; might take a couple hours for Launchpad to sync.

Changed in django-tables:
status: New → Fix Committed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.