Hi, You can use the Django Debug Toolbar <https://github.com/django-debug-toolbar/django-debug-toolbar> to see actual time taken by your queries/templates/... Depending on what is taking time for you, there may be several solutions. If you have issues with your queries, you should take a look at select_related <https://docs.djangoproject.com/en/1.8/ref/models/querysets/#select-related> and prefetch_related <https://docs.djangoproject.com/en/1.8/ref/models/querysets/#prefetch-related> .
On Monday, 1 June 2015 16:21:21 UTC+2, Anandhakumar Radhakrishnan wrote: > > Am using Django 1.7, nginx > > My Django view page having dictionary to render to html. > > Content = { ......} > r = render_to_response('tr/my-content.html',Content, context_instance= > RequestContext(request)) ; t2 = datetime.now() ; print "Elapsed: %.3f" % ( > t2-t1).total_seconds() ; > print (len(r.content)) > return r > > > While calling this view it prints > > Elapsed: 1.993 > > 23254 > > So it take's 2 sec to render a dict to my template . But the page was > loading after 15seconds only. So where is the problem how could I rectify > that. > > > Sample template. > > > > {% extends "base.html" %} > {% load staticfiles %} > {% load thumbnail %} > > {% block title %}<title> My title</title>{% endblock title %} > > {% block extra-css %} > <link href="{% static "css/jquery.mCustomScrollbar.css" %}" rel= > "stylesheet"> > <link href="{% static "css/tooltipster.css" %}" rel="stylesheet"> > {% endblock extra-css %} > > {% block content %} > <div id="{{ mainClass }}" class="main-container"> > <!-- Header Starts Here --> > {% include "pages/header-sub.html" %} > <!-- Header ends Here --> > <!-- Album View --> > <!-- Main cintent area begin --> > <section class="d-mobile"> > {% if trac %} > <ul class="a-contents"> > {{ trac | safe}} > </ul> > {% else %} > <div class="container text-center "> > <p>Your content section is empty. Please use the "upload > file" button at the bottom to begin adding tracks.</p> > </div> > {% endif %} > </section> > </div> > ......... > ......... > {% endblock content %} > > > > In my view file , Am rendering the dict to > > <!-- language: lang-python --> > > Sample Dict: > > > sample = { 'List': u'<li><a > href="/dashboard/performance/?store=Play_list">Play_list</a></li><li><a > href="/drd/page/?sre=Road">Road</a></li><li><a > href="/drd/page/?sre=Sify">Sify</a></li><li><a > href="/drd/page/?sre=Youtube">Youtube</a></li>', 'Date' : u'<li><a > href="/dashboard/performance/?store=Play_list">Play_list</a></li><li><a > href="/drd/page/?sre=Road">Road</a></li><li><a > href="/drd/page/?sre=Sify">Sify</a></li><li><a > href="/drd/page/?sre=Youtube">Youtube</a></li>' ..........} > > > > > from Inspect element: > > Stalled time 4.2 ms > > DNS Look UP : 0 > > Initial Connection : 4.1 ms > > Request Sent : 0.02 ms > > Waiting(TTFB) : 15.5 s > > Content Download: 184 ms > > > > > My nginx setup is > > > user root; > worker_processes 4; > > error_log /var/log/nginx/error.log warn; > pid /var/run/nginx.pid; > > events { > worker_connections 1024; > } > > > http { > include /etc/nginx/mime.types; > default_type application/octet-stream; > > log_format main '$remote_addr - $remote_user [$time_local] > "$request" ' > '$status $body_bytes_sent "$http_referer" ' > '"$http_user_agent" "$http_x_forwarded_for"'; > > access_log /var/log/nginx/access.log main; > > sendfile on; > #tcp_nopush on; > > keepalive_timeout 65; > > gzip on; > gzip_comp_level 2; > gzip_proxied any; > gzip_types text/plain application/javascript > application/x-javascript > text/javascript text/xml text/css; > gzip_vary on; > server_tokens off; > > include /etc/nginx/conf.d/*.conf; > include /etc/nginx/sites-enabled/*; > } > > > > In the sites-enabled/mysite.com > > which has > > upstream test { > server 127.0.0.1:8000; > keepalive 500; > } > > > server { > > listen 80; > server_name www.mysitee.com; > client_max_body_size 4G; > > error_page 502 =200 @maintenance; > > location @maintenance { > root /path/to/static/offline/files; > try_files $uri /index.html =503; > } > location /static/ { > > alias /home/dev/live/staticfiles/; > expires 30d; > } > > location /media/ { > alias /home/dev/live/myproject/myproject/site_media/media/; > expires 30d; > } > location / { > proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; > proxy_set_header Host $http_host; > proxy_redirect off; > if (!-f $request_filename) { > proxy_pass http://test; > break; > } > > } > } > > > > > > Co > ... -- 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+unsubscr...@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. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/37441fc9-b4ff-4590-8151-a9008232d69c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.