On Mon, Dec 23, 2013 at 2:11 PM, Filipe Ferminiano Rodrigues <filipe.ferminiano@gmail.com> wrote:
This is my views.py def piechart(request): responses_pie = AnswerRadio.objects.values("body").annotate(Count("id")) res = [] for cat in responses_pie: res.append([ cat["body"], cat["id__count"], ]) return render(request, 'chart_code_v2.html', {'responses_pie_json': json.dumps(res)})
reponses_pie_json has 2 keys, body - string values - and id__cout - integer values. But, in template, I'm not getting how to input response_pie_json in data of HighCharts. I'm trying to use
data: {{ responses_pie_json|safe }}
But It just show a blank screen. What should i do?
If you're getting a completely blank screen, one of four things is happening:
* You're not hitting the view you think you are. That means your URL definition isn't actually hitting the piechart view - it's matching something else. If you're still in development, try dropping a print statement into the top of the view, and make sure that the right view is being invoked.
* The template file is empty. If chart_code_v2.html is blank, then nothing will be rendered.
* You're not hitting the right template. Are you sure that you know *which* chart_code_v2.html is being rendered? Again, try putting some dummy text into your template and make sure that the file you're saving is the file that is being found by the call to render().
* The page is rendering HTML that contains nothing visible. For example, if your template is *only* rendering a chart, but there's no data being provided, it's possible that the rendered chart is blank. Use the "view source" option of your browser to see if content is actually being rendered; then you can work out if the problem is rendering the right template, or if the problem is in the way you're driving your graphics library.
Once you've worked out which of these is happening, you should be able to sort out a fix fairly quickly.
Yours,
Russ Magee %-)
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJxq84_x9R1n2qDf6vMDgv2%3DJBRVi17-KrHenHXtoOv3kxjCww%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment