RkBlog

Hardware, programming and astronomy tutorials and reviews.

Cool djangosnippets

First snippet is a SQL Query logger middleware which logs and display all queries. The second one is a view profiler middleware which allow

First snippet is a SQL Query logger middleware which logs and display all queries. The second one is a view profiler middleware which allows profiling of views with hotshot. Read more to see example results.

Total query count: 9
 Total execution time: 0.013
0.003: SELECT COUNT(*) FROM "stats_stat" WHERE ("stats_stat"."date" = 2007-05-17 AND "stats_stat"."ip" = 127.0.0.1)
0.001: SELECT "django_session"."session_key","django_session"."session_data","django_session"."expire_date" FROM "django_session" WHERE ("django_session"."session_key" = *** AND "django_session"."expire_date" > 2007-05-17 20:09:39.287943)
0.003: SELECT "rk_topic1"."id","rk_topic1"."topic_name","rk_topic1"."topic_last_pagination_page","rk_topic1"."topic_lastpost" FROM "rk_topic1" ORDER BY "rk_topic1"."topic_modification_date" DESC LIMIT 4 
0.001: SELECT "rk_page1"."id","rk_page1"."title","rk_page1"."slug","rk_page1"."description","rk_page1"."text","rk_page1"."date","rk_page1"."is_category","rk_page1"."wykop_field","rk_page1"."infoneo_field","rk_page1"."jakilinux_field","rk_page1"."digg_field","rk_page1"."reddit_field","rk_page1"."parent_id" FROM "rk_page1" WHERE ("rk_page1"."slug" = index)
0.001: SELECT "rk_com1"."id","rk_com1"."text","rk_com1"."date","rk_com1"."apptype","rk_com1"."appid","rk_com1"."author_id","rk_com1"."ip" FROM "rk_com1" ORDER BY "rk_com1"."id" DESC LIMIT 4 
0.002: SELECT "rk_news1"."id","rk_news1"."title","rk_news1"."slug","rk_news1"."text","rk_news1"."text_more","rk_news1"."is_more","rk_news1"."is_external","rk_news1"."category_id","rk_news1"."date","rk_news1"."jakilinux_field","rk_news1"."wykop_field","rk_news1"."infoneo_field","rk_news1"."digg_field","rk_news1"."reddit_field","rk_ncat1"."id","rk_ncat1"."title","rk_ncat1"."slug","rk_ncat1"."icon" FROM "rk_news1" , "rk_ncat1" WHERE "rk_news1"."category_id" = "rk_ncat1"."id" ORDER BY "rk_news1"."id" DESC LIMIT 5 
0.000: SELECT "rk_page1"."slug","rk_page1"."title" FROM "rk_page1" ORDER BY "rk_page1"."id" DESC LIMIT 6 
0.001: SELECT "rk_task1"."id","rk_task1"."name" FROM "rk_task1" WHERE ("rk_task1"."status" = True) ORDER BY "rk_task1"."modification_date" DESC LIMIT 4 
0.001: SELECT "userpanel_profile"."id","userpanel_profile"."username_id","userpanel_profile"."onsitedata","userpanel_profile"."use_messages" FROM "userpanel_profile" WHERE ("userpanel_profile"."onsitedata" > 2007-05-17 19:09:39.296164) ORDER BY "userpanel_profile"."onsitedata" DESC LIMIT 5 
middleware_prof
middleware_prof1
RkBlog

14 July 2008;

Comment article