Re: Python Graph
2010/1/27 Bhaskar Gara <bacchi28@gmail.com>:
> Hi,
>
> I am very new to django. I am trying to use this library for my
> graphs
> http://www.gerd-tentler.de/tools/pygraphs/?page=introduction
>
>
> In my Views.py
>
> prev_score(request):
> graph = graphs.BarGraph('vBar')
> graph.values = [380, 150, 260, 310, 430]
> print graph.create()
>
> In my Template "score_compare.html" in between the screen I kept
> below code where it need to display the graph.
>
> {{ prev_score }}
>
> It not erroring out, but the graph is not displaying. Please help.
>
> Thank you
> Bhaskar
Within a view function you can't print html out, you need to return
the output of the function.
So, using your example, this should give you your graph:
from django.template import loader, Context
def prev_score(request):
graph = graphs.BarGraph('vBar')
graph.values = [380, 150, 260, 310, 430]
myGraph = graph.create()
t = loader.get_template('my_template.html')
c = Context({ 'graph': myGraph })
return HttpResponse(t.render(c))
Have a read through this part of the documentation:
http://docs.djangoproject.com/en/1.1/topics/http/views/#topics-http-views
HTH
Dan
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>
>
--
Dan Hilton
============================
www.twitter.com/danhilton
www.DanHilton.co.uk
============================
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home