I'm thinking of using a raw query to quickly get around limitations with either my brain or the Django ORM, but I don't want to redevelop the infrastructure required to support the existing ORM code such as filters. Right now I'm stuck with two dead ends:
Writing an inner raw query and reusing that like any other query set. Even though my raw query selects the correct columns, I can't filter on it:
AttributeError: 'RawQuerySet' object has no attribute 'filter'
This is corroborated by another answer, but I'm still hoping that that information is out of date.
- Getting the SQL and parameters from the query set and wrapping that in a raw query. It seems the raw SQL should be retrievable using
queryset.query.get_compiler(DEFAULT_DB_ALIAS).as_sql()
- how would I get the parameters as well (obviously without actually running the query)?