I have my logo and css files at
/Users/harijay/learn_css/logo.png
/Users/harijay/learn_css/my_master.css
STATIC_ROOT="/Users/harijay/learn_css/"
STATIC_URL="/static/"
My Django project directory is
/Users/harijay/learn_django
I am not using anything extra in my urls.py (attached below). in my template I am composing my static links as follows
t = Template (""".....
@import url("{{STATIC_URL}}my_master.css");
<img src="{{STATIC_URL}}logo.png"/>
""")
And returning the response as follows
c = RequestContext(request)
return (HttpResponse(t.render(c)))
My problem is that the logo.png and my_master.css only get served if they are put in the project directory i.e /Users/harijay/learn_django
They are showed at the URL http://localhost:8000/static/logo.png
I am trying to understand what I am doing wrong. I had gotten suggestions on the irc channel to use django_appmedia but I want to go with staticfiles app since it is better documented.
Any Help will be greatly appreciated
Hari
###########
urls.py
###########
from django.conf.urls.defaults import *
from bscencoder.views import hello
from bscencoder.views import upload_to_s3_form
from bscencoder.views import mymain
import settings
#from django.contrib.staticfiles.urls import staticfiles_urlpatterns
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
# Old method of serving static files with devserv
#(r'^(?P<path>.*)$', 'django.views.static.serve',{'document_root': '/Users/harijay/learn_css'}),
urlpatterns = patterns('',
# Example:
# (r'^bscencoder/', include('bscencoder.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
# (r'^admin/', include(admin.site.urls)),
(r'^/?$',mymain),
(r'^hello/?',hello),
(r'^upload/?',upload_to_s3_form),
)
#if settings.DEBUG: # assuming dev server
# urlpatterns += patterns(r'^(?P<path>.*)$', 'django.views.static.serve',{'document_root': STATIC_ROOT })
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment