Skip to content

Commit

Permalink
Create separate branch for issue #49. Print in console and in JSON file
Browse files Browse the repository at this point in the history
all the SQL queries that take place in Announcements tab for debugging
  • Loading branch information
Theo Chatzimichos committed Nov 18, 2012
1 parent 5555485 commit 7a68a57
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cronos/posts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))

0 comments on commit 7a68a57

Please sign in to comment.