Dynamically Creating Plots for Django Using Matplotlib

I will make this short and sweet. Django 1.5. Matplotlib 1.3. I wanted to generate some plots and send then to the client as an HTTP response. Much like the method in the Django docs for sending out a CSV.

Googling around showed two general approaches:

Neither worked. The Django url was:

urlpatterns = patterns(
    url(r'^graph.png/$', views.graph),

But when I switched it to:

urlpatterns = patterns(
    url(r'^graph.png$', views.graph),

Both methods worked. Ouch. I will never get those 2 hours of my life back.




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s