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
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.