when i use connection.queries in django i get a weird exception:
'list' object is not callable
which isn’t very clear to me. Here is the code i am running:
def myOtherFunction(request):
return arrangeCountOfItems(Story.objects.filter(user=request.user.id).order_by('-create_date'))
def arrangeCountOfItems(storyList):
for story in storyList:
story.rateA = story.post_set.filter(rating=RATEA).count()
story.rateB = story.post_set.filter(rating=RATEB).count()
story.rateC = story.post_set.filter(rating=RATEC).count()
print connection.queries()
return storyList
i’m kinda trying to work out how to to filter by a foreign key’s foreign key (something i’m also just about to ask here!) and thought i’d try to work out what is going on from the query… but no dice!
connection.queriesis a list with SQL queries, it’s not a callable function.See this example in the Django documentation for example. You can do the following instead: