How not to explicly write very very big json object when rendering page in django template ?

69 views
Skip to first unread message

Matlau Issu

unread,
Nov 2, 2014, 4:59:34 PM11/2/14
to django...@googlegroups.com
I mean, in my views.py i do :    
return render(request, 'myapp/detail.html', { pydic_jsonized  :  json.dumps(python_dict)   }  )

then in my html, i get pydic_jsonized with
<script>
var json = {{ pydic_jsonized  }};
</script>

But pydic_jsonized is just furiously big, and is written as harded coded data in the html page, which subsequently takes a very long time to load (30s). Is there a mean to retrieve data in the js script in an abstract manner ?

Thanks

Vijay Khemlani

unread,
Nov 2, 2014, 6:41:43 PM11/2/14
to django...@googlegroups.com
Do you really need all the data in that dictionary for the page? You could request the necessary parts by AJAX after the page has loaded.

--
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...@googlegroups.com.
To post to this group, send email to django...@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/7b871c16-929a-40b0-8e7f-a62349a98657%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Matlau Issu

unread,
Jan 15, 2015, 8:10:23 AM1/15/15
to django...@googlegroups.com
OK. AJAX is the solution.
Reply all
Reply to author
Forward
0 new messages