Hi,

I've a project photo and an application gallery. I want to do a very
simple thing: When the URL http://localhost:8000/gallery/ is accessed,
a page will be displayed containing a single image. I've set the
necessary variables and mapped the URLs.

The problem is, in the base.html template (where I'm using
{{ MEDIA_URL }} to denote the path of the image), the value of the
variable MEDIA_URL is not getting substituted -- it appears as blank.

For example, with the following settings:

[photo/settings.py]
DEBUG = True
MEDIA_ROOT = '/home/barun/codes/python/django/test/photo/media/'
MEDIA_URL = '/gallery/s_media/'

[photo/urls.py]
(r'^gallery/', include('photo.gallery.urls')),

[gallery/urls.py]
urlpatterns = patterns('',
    (r'^$', 'photo.gallery.views.index'),
    (r'^s_media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
)

[gallery/views.py]
def index(request):
        return render_to_response('base.html', {})

[templates/base.html]
<img src="{{ MEDIA_URL }}images/header/gear_blue_lab.png" alt="Gear" /
>


when the HTML page is finally displayed in the browser, the image
source appears as
<img src="images/header/gear_blue_lab.png" alt="Gear" />

Could anyone please suggest on this?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.

Reply via email to