0

I have this configuration in my settings.py file

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'corsheaders',
    'dashboard',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.debug',
    'django.core.context_processors.i18n',
    'django.core.context_processors.media',
    'django.core.context_processors.static',
    'django.core.context_processors.tz',
    'django.contrib.messages.context_processors.messages',
    'django.core.context_processors.request',
    'social.apps.django_app.context_processors.backends',
    'social.apps.django_app.context_processors.login_redirect',
)

STATIC_URL = '/static/'

STATIC_ROOT = '/home/workspace/app-toscana/django/djangoapptoscana/djangoapptoscana/static'

My Django project is located in the following directory:
/home/workspace/app-toscana/django/djangoapptoscana

Inside this directory the project structure is the following one

.
├── dashboard
│   ├── admin.py
│   ├── admin.pyc
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── models.py
│   ├── models.pyc
│   ├── templates
│   │   ├── index.html
│   │   ├── loginpage.html
│   │   ├── registerpage.html
│   │   └── startpage.html
│   ├── tests.py
│   ├── views.py
│   └── views.pyc
├── djangoapptoscana
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── settings.py
│   ├── settings.pyc
│   ├── static
│   │   └── admin
│   │       ├── css
│   │       │   ├── ...
│   │       ├── img
│   │       │   ├── ...
│   │       └── js
│   │           ├── ...
│   │   └── bootstrap
│   │       ├── css
│   │       │   ├── bootstrap.css
│   │   └── ....
│   ├── urls.py
│   ├── urls.pyc
│   ├── wsgi.py
│   └── wsgi.pyc
└── manage.py

Here it is a code snapshot of my dashboard/template/index.html

{% load staticfiles %}
...
<link href="{% static 'bootstrap/css/bootstrap.css' %}" rel="stylesheet" type="text/css" />
...

When I try to test the project using python manage.py runserver 0.0.0.0:8000 I'm not able to serve static files receiving 404 error.
I'm running Django 1.6.1 version.
Any suggestion? Thanks!

neoben
  • 743
  • 12
  • 30

1 Answers1

1

Please try specifying STATICFILES_DIRS in settings.py file.

STATICFILES_DIRS = '/home/workspace/app-toscana/django/djangoapptoscana/djangoapptoscana/static'

STATIC_ROOT is the absolute path to the directory where ./manage.py collectstatic will collect static files for deployment. Create static_cdn folder at the following path.

STATIC_ROOT = '/home/workspace/app-toscana/django/static_cdn'

This stack overflow link and this one should help you.

Community
  • 1
  • 1
Jomy
  • 368
  • 4
  • 11