[Answered ]-Custom stylesheets in Django (1.3) admin

1đź‘Ť

Are you having this problem on your local dev environment (with runserver)? If so, do you have the following in your urls.py?

from django.contrib.staticfiles.urls import staticfiles_urlpatterns

# ... the rest of your URLconf goes here ...

urlpatterns += staticfiles_urlpatterns()

Read the Django Docs for more.

👤Aaron Beals

1đź‘Ť

Ok, I now think I know what’s going on here. Hopefully this will clarify:

STATIC_ROOT is only used by the “collectstatic” management command, to figure out where to dump the static files it collects.

STATIC_URL is used by the dev server to define the URL at which the static files will be served.

STATICFILES_DIRS, which you haven’t set, is used by both the dev server and the “collectstatic” management command to identify the locations of the static files to serve. In the case of the dev server, the files are served directly in place. In the case of the management command, the files are gathered and copied into STATIC_ROOT.

[Note: there’s a convention here — if you have /static subdirectories in your apps (not your project), they’ll be picked up along with anything explicitly defined in STATICFILES_DIRS.]

You just need to add the following to settings.py:

STATICFILES_DIRS = {
        '/absolute/path/to/myproject/static/',
}
👤Aaron Beals

Leave a comment