Django 1.2 Equivalent of QuerySet.query.as_sql()

后端 未结 2 491
抹茶落季
抹茶落季 2020-12-11 15:53

In Django 1.1 I was able to produce the SQL used by a QuerySet with this notation:

QuerySet.query.as_sql()

In Django 1.2, this

相关标签:
2条回答
  • 2020-12-11 16:33

    as answered in In django 1.2.1 how can I get something like the old .as_sql?

    it's just:

    print QuerySet.query
    
    0 讨论(0)
  • 2020-12-11 16:53

    In Django 1.1, QuerySet.query returned a BaseQuery object, now it returns a Query objects. The query object has a __str__ method defined that returns the SQL.

    0 讨论(0)
提交回复
热议问题