0

enter image description here

I'm currently trying to get the styles to load for my index page and am not having any luck. The above illustrates my current file structure. DEBUG = True and I have run collectstatic to no avail. I'm assuming it's all a basic directory mapping issue, but can't seem to figure it out. Thanks in advance.

settings

STATIC_URL = '/static/'

STATIC_ROOT = os.path.join(BASE_DIR, 'static')

URLS

from django.conf.urls import include, url
from django.contrib import admin
from homepage.views import main_page
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [

    url(r'^$', main_page, name = 'home'),
    url(r'^admin/', include(admin.site.urls)),

] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

html snippet

{% load staticfiles %}
<link href="{% static 'css/style.css' %}" rel="stylesheet">
<link href="{% static 'css/font-awesome.min.css' %}" rel="stylesheet">
<link href="{% static 'css/bootstrap.css' %}" rel="stylesheet">

ERROR

'static/css/bootstrap.css' could not be found
16
  • You have static/static/css/bootstrap.css in your folder structure, no? Commented May 21, 2015 at 5:57
  • that is correct, is that a problem? Commented May 21, 2015 at 5:59
  • try: STATIC_ROOT = os.path.join(BASE_DIR, 'static/static') Commented May 21, 2015 at 5:59
  • You have created another static directory inside the static , that is causing the problem. Remove the extra static directory. Commented May 21, 2015 at 6:01
  • I removed the second static directory and still get the error. <link href="{% static 'css/bootstrap.css' %}" rel="stylesheet"> I knew it wasn't an issue, but I know having a single static directory is better. Commented May 21, 2015 at 6:03

1 Answer 1

2

You're confusing a couple of staticfiles topics.

First, you need to define STATICFILES_DIRS in your settings.py. This needs to be different than your STATIC_ROOT (which doesn't need to be set in development with DEBUG = True):

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)

If you want to define STATICFILES_ROOT, this needs to be different than the above. The STATICFILES_ROOT is the location where collectstatic will "collect" static files from your STATICFILES_DIRS, for production.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.