I'm just starting with django 1.6 and my css is not working neither my images, I get a 404 error, even the admin(s css is not working
Here is my file structure :
myproject
--myproject
----templates
--static
----css
----media
--myapp
--mp.db
--manage.py
This is my base.html :
<link rel="image_src" href="{% block image_src %}http://{{ request.META.HTTP_HOST }}/static/images/logo.png{% endblock %}" />
<link rel="stylesheet" media="screen" href="{{ STATIC_URL }}css/utils.css">
<link rel="stylesheet" media="screen" href="{{ STATIC_URL }}css/{% block style_link %}style{% endblock %}.css">
...
<div id="cont_footer" class="container centerAuto">
<img src="{{ MEDIA_URL }}images/logo_footer.png" alt="" />
</div>
This is my settings :
PROJECT_ROOT = os.path.dirname( __file__ )
PROJECT_NAME = os.path.basename(PROJECT_ROOT)
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static/')
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
os.path.join(PROJECT_ROOT, 'static/'),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.static',
)
MEDIA_URL = STATIC_URL +'media/'
MEDIA_ROOT = os.path.join(PROJECT_ROOT, *MEDIA_URL.strip("/").split("/"))
In urls.py :
urlpatterns = patterns('',
url(r'^$', TemplateView.as_view(template_name='index.html'), name="index"),
url(r'^admin/', include(admin.site.urls)),
) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
What am I doing wrong?I'm pulling my hair off because of this since three days now!!
Thanks
Make folder "static" in root of your project where settings.py exists
In settings.py
In base.html
In other template files in which you include base.html
urls.py