Comment 1 for bug 503652

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