0

I'm using Ubuntu and Django 1.3.7. Following are the various relevant settings:

My directory structure:

mysite/
      manage.py
      settings.py
      __init__.py
      urls.py
      myapp/
          __init__.py
          forms.py
          models.py
          views.py
          templates/
               index.html
               home.html
      static/
           common.css
           ...
           ...

My settings.py file:

import os.path
SETTINGS_ROOT = os.path.dirname(__file__)
INSTALLED_APPS = (
    ...
    ...
       'django.contrib.staticfiles'
    )
    STATIC_ROOT = os.path.join(SETTINGS_ROOT, "static/")
    STATIC_URL = '/static/'

In my templates html file:

<link rel="stylesheet" type="text/css" href="/static/bootstrap/css/bootstrap.css">

Still, the pages don't show any images, css or js files. I've read the docs. But nothing helps. What else do I need to include/modify in order to get the files running?

xan
  • 4,640
  • 13
  • 50
  • 83

3 Answers3

0
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
    '/path/to/your/project/assets',
)
mVChr
  • 49,587
  • 11
  • 107
  • 104
0

settings.py

import os
SETTINGS_ROOT = os.path.dirname(__file__)

STATIC_ROOT = os.path.join(SETTINGS_ROOT, "static")
STATIC_URL = '/static/'

STATICFILES_DIRS = (

    os.path.join(SETTINGS_ROOT, 'static'),
)

main urls.py

from django.conf.urls import patterns, include, url
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns

admin.autodiscover()

urlpatterns = patterns('',
    ................
) 

urlpatterns += staticfiles_urlpatterns()

template

<link rel="stylesheet" type="text/css" href="/static/bootstrap/css/bootstrap.css">
catherine
  • 22,492
  • 12
  • 61
  • 85
0

my static file configurions are below.

PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
enter code herePER_DIR = os.path.abspath(os.path.join(PROJECT_DIR, os.path.pardir))
STATIC_ROOT = os.path.join(SUPER_DIR, 'static')
STATIC_URL = '/static/'

it might help

Sandeep Balagopal
  • 1,943
  • 18
  • 28