Re: Unable to display static content.
Are you sure you read this?: https://docs.djangoproject.com/en/1.3/ref/contrib/staticfiles/ >From my own experience, storing my static files in '/static/' never works so I always create a separate folder for my static files and add the path to STATICFILES_DIRS in my settings. On 1/1/12, Chirdeepwrote: > Now I have changed the project structure to > > Project > -webApp > ---static > -images > -stylesheets > -index.html > ---templates > > I can browse to index.html inside static folder. > > http://127.0.0.1:8000/static/index.html > > For some reason, its adding the search-form to the URL for loading CSS > and Images when I browse to http://127.0.0.1:8000/search-form/ > > Firebug shows : > http://127.0.0.1:8000/search-form/common.css > > Obviously then it won't find the resources. > > > -- > 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+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Sent from my mobile device -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Unable to display static content.
Now I have changed the project structure to Project -webApp ---static -images -stylesheets -index.html ---templates I can browse to index.html inside static folder. http://127.0.0.1:8000/static/index.html For some reason, its adding the search-form to the URL for loading CSS and Images when I browse to http://127.0.0.1:8000/search-form/ Firebug shows : http://127.0.0.1:8000/search-form/common.css Obviously then it won't find the resources. -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Unable to display static content.
use {{STATIC_URL}} in place of {{MEDIA_URL}} and keep STATIC_ROOT =' ' in settings page. refer : https://docs.djangoproject.com/en/dev/howto/static-files/ On Sat, Dec 31, 2011 at 7:42 AM, Chirdeepwrote: > Hi All, > > I am just learning Python and Django. I am able to see the webpage but > css and images are not picked up. > > Configuration as below: > > Linux Ubuntu 11.04 > Python 2.7.2 > Django 1.3.1 > > I have setup Django using VirtualEnv. I am using PyCharm and my Django > project is pointing to the VirtualEnv Django installation. > > In firebug, I am getting 404 for css and images. > > Project Structure. > > ProjectRoot > -media > -images > -stylesheets > -templates > -webapp > > urls.py > > -- > from django.conf.urls.defaults import patterns, include, url > import settings > from talenthunt.web import views > > urlpatterns = patterns('', >url(r'^search-form/$', views.search_form), >url(r'^search/$', views.search), > ) > > if settings.DEBUG: >urlpatterns += patterns('', >(r'^media/(?P.*)$', 'django.views.static.serve', { >'document_root': settings.MEDIA_ROOT})) > > > settings.py > > --- > def rel(*x): >return os.path.join(os.path.abspath(os.path.dirname(__file__)), > *x ) > > MEDIA_ROOT = rel('media') > MEDIA_URL = '/media/' > > STATIC_ROOT = rel('static') > STATIC_URL = '/static/' > > ADMIN_MEDIA_PREFIX = '/media/admin/' > > Only pasting relevant code from settings.py > > Base.html > > -- > > >Organic Web Design > rel="stylesheet" type="text/css" /> > > > Any help will be much appreciated. > > Thanks > Chirdeep > > > > -- > 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+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Unable to display static content.
Hi All, I am just learning Python and Django. I am able to see the webpage but css and images are not picked up. Configuration as below: Linux Ubuntu 11.04 Python 2.7.2 Django 1.3.1 I have setup Django using VirtualEnv. I am using PyCharm and my Django project is pointing to the VirtualEnv Django installation. In firebug, I am getting 404 for css and images. Project Structure. ProjectRoot -media -images -stylesheets -templates -webapp urls.py -- from django.conf.urls.defaults import patterns, include, url import settings from talenthunt.web import views urlpatterns = patterns('', url(r'^search-form/$', views.search_form), url(r'^search/$', views.search), ) if settings.DEBUG: urlpatterns += patterns('', (r'^media/(?P.*)$', 'django.views.static.serve', { 'document_root': settings.MEDIA_ROOT})) settings.py --- def rel(*x): return os.path.join(os.path.abspath(os.path.dirname(__file__)), *x ) MEDIA_ROOT = rel('media') MEDIA_URL = '/media/' STATIC_ROOT = rel('static') STATIC_URL = '/static/' ADMIN_MEDIA_PREFIX = '/media/admin/' Only pasting relevant code from settings.py Base.html -- Organic Web Design Any help will be much appreciated. Thanks Chirdeep -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.