I mis-read this... basically you have one view and in the template you are rendering you put HTML:
<img src="/some/path/to/a/view" /> <img src="/some/path/to/a/view" /> so that path will call your other views which return content as content_type='image/png' or whatever specific format you're using. what i was suggesting is you could have: <img src="/some/path/to/a/view/?foo=1" /> <img src="/some/path/to/a/view/?foo=2" /> <img src="/some/path/to/a/view/?foo=3" /> So in your urls.py file it would parameratize 'foo' and in your view method you could produce different responses based on the parameter. Eg: in an other view i have i can pass lat and long coords as params and it would put a dot on the map based on where that lat/long points to. On Tue, Apr 12, 2011 at 2:19 PM, nai <chng.nai...@gmail.com> wrote: > Actually, could you illustrate how you would go about using 2 views as > well? Thanks! > > On Apr 11, 6:39 pm, Xavier Ordoquy <xordo...@linovia.com> wrote: >> Le 11 avr. 2011 à 12:21, nai a écrit : >> >> >> >> >> >> >> >> >> >> > This is the give example from Matplotlib for Django: >> >> > def simple(request): >> > import random >> >> > from matplotlib.backends.backend_agg import FigureCanvasAgg as >> > FigureCanvas >> > from matplotlib.figure import Figure >> > from matplotlib.dates import DateFormatter >> >> > fig=Figure() >> > ax=fig.add_subplot(111) >> > x=[] >> > y=[] >> > now=datetime.datetime.now() >> > delta=datetime.timedelta(days=1) >> > for i in range(10): >> > x.append(now) >> > now+=delta >> > y.append(random.randint(0, 1000)) >> > ax.plot_date(x, y, '-') >> > ax.xaxis.set_major_formatter(DateFormatter('%Y-%m-%d')) >> > fig.autofmt_xdate() >> > canvas=FigureCanvas(fig) >> > response=django.http.HttpResponse(content_type='image/png') >> > canvas.print_png(response) >> > return response >> >> > Is there anyway I can return the image like this `return >> > render_to_response('template.html', {'graph': <graph generated by >> > matplotlib or some other graphing package>}` >> >> Hi, >> >> Is there any reasons why you couldn't have a view that would just render the >> image and the other one that would have a img tag pointing to the first view >> ? >> It is possible to embed an image in the web page, but I'm sure it goes >> against the best practices. >> >> Regards, >> Xavier. > > -- > 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+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.