As of 1.2 and multi-db how do I get the sql that will be produced from a query set ?
Since 1.2 and multi-db, the previous methods are no longer working. Its been said here that we shouldn't depend on internal functions as they may change. However getting the SQL that will be produced is essential. There needs to be a utility method somewhere that will give us this sql and it needs to remain stable. If the class structure and implementation gets moved around then this utility method would be updated to continue to offer this most basic and essential of debugging tools. (Pdb) qs.query <django.contrib.gis.db.models.sql.query.GeoQuery object at 0x3fd10d0> (Pdb) qs.query.as_sql() *** AttributeError: 'GeoQuery' object has no attribute 'as_sql' (Pdb) qs.query.compiler 'GeoSQLCompiler' Please let's not assume that Django's ORM is completely magical and we should never have need to investigate what it is doing. SELECT "nsproperties_apt"."id" FROM "nsproperties_apt" INNER JOIN "fastadder_fastadderstatus" ON ("nsproperties_apt"."id" = "fastadder_fastadderstatus"."apt_id") INNER JOIN "nsproperties_apt_agents" ON ("nsproperties_apt"."id" = "nsproperties_apt_agents"."apt_id") WHERE ("nsproperties_apt"."is_available" = True AND "nsproperties_apt"."list_on_web" = True AND "nsproperties_apt"."id" IN (SELECT U0."id" FROM "nsproperties_apt" U0 INNER JOIN "fastadder_fastadderstatus" U1 ON (U0."id" = U1."apt_id") INNER JOIN "nsproperties_apt" U2 ON (U1."apt_id" = U2."id") INNER JOIN "nsproperties_apt_agents" U3 ON (U2."id" = U3."apt_id") INNER JOIN "fastadder_fastadderstatus" U5 ON (U0."id" = U5."apt_id") INNER JOIN "fastadder_fastadderstatus" U6 ON (U0."id" = U6."apt_id") WHERE (U0."is_available" = True AND U0."list_on_web" = True AND U3."agent_id" = 175 AND U5."running_status" = 2 AND U6."priority" >= 1 AND U6."agent_priority" = 1 )) AND "fastadder_fastadderstatus"."service_id" = 4 AND "nsproperties_apt_agents"."agent_id" = 175 ) When I get garbage like this I need to investigate different points in my chain and see how the query evolved to this point. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.