3

I have simple model like this:

class Something(models.Model):
    data = models.CharField(max_length=200)

And when Im performing this:

Something.objects.all().query

I get this:

<django.db.models.sql.query.Query object at 0xa57b9ec>

What is it mean? Im using newest version of Django (1.5.2). In older versions .query was returned a string with the SQL query. How can I get it in new version?

3
  • what happens when you print your Query object? print(Something.objects.all().query), What version of django are you on? What environment are you inspecting .query? github.com/django/django/blob/master/django/db/models/sql/… Commented May 29, 2013 at 19:31
  • 2
    does Something.objects.all().query.__str__() work? Commented May 29, 2013 at 19:33
  • @Alp yep, str() is helped. Everything appeared out to be not so hard :) Commented May 29, 2013 at 19:40

1 Answer 1

5

As we found out in the comments, that's your answer:

str(Something.objects.all().query)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.