1

I am trying to get an existing django app up and running, but the css or any other static files are not showing up. I get the error:

"GET /static/css/mycss.css HTTP/1.1" 404 50

In the settings the following values are used:

DJANGO_ROOT = dirname(dirname(abspath(__file__)))
SITE_ROOT = dirname(DJANGO_ROOT)
STATIC_ROOT = normpath(join(SITE_ROOT, 'assets'))
STATIC_URL = '/static/'

STATICFILES_DIRS = (
    normpath(join(SITE_ROOT, 'static')),
)

The app contains a directory called "static". It is in the current directory structure:

my-django-project > my-django-project > static > css > mycss.css

When I hit the home url via localhost, I get the above 404 error.

What am I doing wrong?

Atma
  • 29,141
  • 56
  • 198
  • 299
  • 1
    You need to post your webserver configuration as well. Django usually doesn't serve static files at all, you're supposed to configure your webserver to handle those requests directly. – lanzz Mar 26 '14 at 23:06

1 Answers1

0

You need to run the collectstatic command to collect the static files in your apps to the STATIC_ROOT.

The command can be run like this:

python managy.py collectstatic

More information about static files can be found in the django documentation on static files.

HAL
  • 2,011
  • 17
  • 10
  • i collected all the static files, I am still getting the 404s – Atma Mar 26 '14 at 22:54
  • ok, was a new directory `my-django-project > static` created that contains the static files from your app ? – HAL Mar 26 '14 at 22:57
  • I see. Updated my answer with information about where static files are collected (´STATIC_ROOT` and not `STATICFILES_DIR`). – HAL Mar 26 '14 at 23:10
  • Are you using the development server (i.e. `./manage.py runserver`) or some other webserver? – HAL Mar 26 '14 at 23:11
  • Check that some static file from the app actually exists in the `assets` dir (i.e. `assets/css/mycss.css`) and check that the `django.contrib.staticfiles` are in your `INSTALLED_APPS` (https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-during-development). – HAL Mar 26 '14 at 23:18