From 7a68a57f0544f3ef4a1b6a233333825864a19b83 Mon Sep 17 00:00:00 2001 From: Theo Chatzimichos Date: Sun, 18 Nov 2012 20:14:34 +0100 Subject: [PATCH] Create separate branch for issue #49. Print in console and in JSON file all the SQL queries that take place in Announcements tab for debugging --- cronos/posts/views.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cronos/posts/views.py b/cronos/posts/views.py index 1a17b1e..b6cd54e 100644 --- a/cronos/posts/views.py +++ b/cronos/posts/views.py @@ -5,8 +5,10 @@ from cronos.teilar.models import Teachers as teachers from cronos.teilar.models import Websites as websites from cronos.teilar.models import EclassLessons as eclasslessons +from django.conf import settings from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType +from django.db import connection from django.http import HttpResponseRedirect from django.shortcuts import render_to_response from django.template import RequestContext @@ -182,4 +184,10 @@ def posts(request, id, page, template = "posts.html", extra_context = None): context = {'posts': posts, 'title': title} if extra_context: context.update(extra_context) + # Show SQL queries in console output + print connection.queries + # Write the SQL queries in a JSON file + f = open('/tmp/%s/posts_queries.json' % settings.INSTANCE_NAME, 'w') + f.write(str(connection.queries)) + f.close() return render_to_response(template, context, context_instance = RequestContext(request))