4

I'm probably doing multiple things wrong here because I still can't get static files to work correctly in my development environment despite closely following the tutorial. I have a feeling it's because it works slightly differently in Django 1.6, and I can only find answers for previous versions.

Here's my directory structure:

mysite
├───app1
├───mysite
│   └───templates
├───resources
├───static
│   ├───css
│   ├───fonts
│   └───js
└───app2

My installed apps, to prove I have staticfiles on:

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'app1',
    'app2',
)

My template and static file settings:

 # Templates
TEMPLATE_DIRS = (
    os.path.join(BASE_DIR, "mysite/templates"),
)

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/

STATIC_URL = '/static/'

I even did this in my urls.py as suggested:

urlpatterns = patterns('',
    ...
) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

And finally, my request:

{% load staticfiles %}
<link href="{% static "css/core.css" %}" rel="stylesheet">

If I navigate directly to http://127.0.0.1/static/css/core.css, I get 'css\core.css' could not be found

Please tell me what I did wrong =[

4

1 に答える 1