image & css file location setup

In settings.py

STATIC_DOC_ROOT = os.path.join(os.path.dirname(__file__), “static”)

MEDIA_URL = ‘/static/’

——————–

In urls.py
from django.conf import settings
if settings.DEBUG:
urlpatterns += patterns(”,
(r’^static/(?P<path>.*)$’, ‘django.views.static.serve’, {‘document_root’: settings.STATIC_DOC_ROOT }),
)

————-

In template .html

<h1><a href=”/”><img src=”{{ MEDIA_URL }}images/logo.png” alt=”Your Logo” title=”Your website”/></a></h1>

———-

directory structure

yourapp/static/images/

Leave a Comment