Archive for January, 2012

A very django meandering

January 7, 2012

I’m currently trying to get http://www.lightbird.net/dbe/photo.html this tutorial to work.  I’ve succeeded in getting the basics to display, except for the images!  Which of course is a bit silly, since that is the whole point of the tutorial.  So far I’ve discovered that firefox seems to like things being served in html as file://localhost/[your local location of file] but I understand that this is bad coding practice; it is far better to keep paths relative.

Even so, when I tried to directly reference an image in django I found that the html parsed correctly in firefox, even that which was generated, but did not on the django server!  This has caused me some puzzlement.  Currently I am investigating the suggestion (at the original page) and also backed up by a comment (with zero upvotes) at stackoverflow here: http://stackoverflow.com/questions/2443752/django-display-image-in-admin-interface in order to see if modification of the base admin template might work.

My development environment is eclipse.

UPDATE: Turns out that the problem was with my urls.py file.

#urls.py…..

#… import statements…

from tutorial3_lightbird.settings import MEDIA_ROOT

urlpatterns = patterns(”,
#… ,
(r’^media/(?P<path>.*)$’, ‘django.views.static.serve’,{‘document_root’: MEDIA_ROOT}),
)

Turns out that I was using the MEDIA_URL value from settings.py before.  Rookie mistake.