Saturday, August 31, 2013

Re: db queries made twice

Thanks, though disabling django_toolbar completely (removing the
middleware, and the entry in INSALLED_APPS) did not helped.

Regards,
Marcin

On 04:34 Sat 31 Aug , Tomáš Ehrlich wrote:
> Other option is set SHOW_TEMPLATE_CONTEXT to False
> in DEBUG_TOOLBAR_CONFIG.
>
> See https://github.com/django-debug-toolbar/django-debug-toolbar#configuration
>
> Dne sobota, 31. srpna 2013 13:24:54 UTC+2 Tomáš Ehrlich napsal(a):
> >
> > Hi,
> > disable Template panel in debug_toolbar and try again.
> >
> > Debug toolbar hits database when evaluating template context.
> >
> >
> > Cheers,
> > Tom
> >
> > Dne Sat, 31 Aug 2013 12:09:00 +0100
> > Marcin Szamotulski napsal(a):
> >
> > > Hello,
> > >
> > > I am using django-1.6.b2 on a localserver (./manage.py runserver) and
> > > for every request I have the chain of db lookups made twice. For
> > > example my log looks something like this (after enabling
> > > django.db.backands logger):
> > >
> > > # HERE VIEW IS CALLED
> > > (0.001) SELECT "django_session"."session_key",
> > "django_session"."session_data", "django_session"."expire_date" FROM
> > "django_session" WHERE ("django_session"."session_key" =
> > '2dh8ly6cfqkyiauv8co5h1vossjg70ru' AND "django_session"."expire_date" >
> > '2013-08-31 11:04:33.597734+00:00' );
> > args=('2dh8ly6cfqkyiauv8co5h1vossjg70ru', u'2013-08-31
> > 11:04:33.597734+00:00')
> > > (0.001) SELECT "auth_user"."id", "auth_user"."password",
> > "auth_user"."last_login", "auth_user"."is_superuser",
> > "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name",
> > "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active",
> > "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1 ;
> > args=(1,)
> > >
> > > #... (AND SO ON)
> > >
> > > # HERE VIEW CALL IS FINISHED
> > > [31/Aug/2013 12:04:33] "GET /coot/ HTTP/1.1" 200 220974
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/css/style.css HTTP/1.1"
> > 304 0
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/js/jquery.js HTTP/1.1"
> > 304 0
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/js/jquery-ui.js HTTP/1.1"
> > 304 0
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/js/posts.js HTTP/1.1" 304
> > 0
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/js/confirm.js HTTP/1.1"
> > 304 0
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/css/posts.css HTTP/1.1"
> > 304 0
> > > [31/Aug/2013 12:04:34] "GET
> > /site_media/static/debug_toolbar/css/toolbar.min.css HTTP/1.1" 304 0
> > > [31/Aug/2013 12:04:34] "GET
> > /site_media/static/debug_toolbar/js/toolbar.min.js HTTP/1.1" 304 0
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/pics/django_logo.png
> > HTTP/1.1" 304 0
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/pics/python_logo.png
> > HTTP/1.1" 304 0
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/css/whitey.png HTTP/1.1"
> > 304 0
> > > [31/Aug/2013 12:04:34] "GET /site_media/static/css/stressed_linen.png
> > HTTP/1.1" 304
> > >
> > > # DB LOOKUPS ONCE AGAIN:
> > > (0.001) SELECT "django_session"."session_key",
> > "django_session"."session_data", "django_session"."expire_date" FROM
> > "django_session" WHERE ("django_session"."session_key" =
> > '2dh8ly6cfqkyiauv8co5h1vossjg70ru' AND "django_session"."expire_date" >
> > '2013-08-31 11:04:33.597734+00:00' );
> > args=('2dh8ly6cfqkyiauv8co5h1vossjg70ru', u'2013-08-31
> > 11:04:33.597734+00:00')
> > > (0.001) SELECT "auth_user"."id", "auth_user"."password",
> > "auth_user"."last_login", "auth_user"."is_superuser",
> > "auth_user"."username", "auth_user"."first_name", "auth_user"."last_name",
> > "auth_user"."email", "auth_user"."is_staff", "auth_user"."is_active",
> > "auth_user"."date_joined" FROM "auth_user" WHERE "auth_user"."id" = 1 ;
> > args=(1,)
> > >
> > > ... (AND SO ON)
> > >
> > >
> > > any ideas why?
> > >
> > > The views (as it is not just one) returns using render(). This also
> > > happens when using DetailedView cbv.
> > >
> > > I also setup looking on postgres (which I use) and indeed the queries
> > > are made twice.
> > >
> > > Thanks for ideas,
> > > Marcin
> > >
> >
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment