[Answer]-Setting static background image in local Django environment

2👍

Your css file is not rendered by Django template engine and so {{ STATIC_URL }} is not being replaced. You’ll have to use /static/img/IMG_0002.jpg in the CSS file or move that bit of CSS in your html file’s style tag.

👤Rahul

-1👍

Try this

settings.py

MEDIA_URL = '/static_media/'

urly.py

if settings.DEBUG:

    urlpatterns += patterns('django.views.static',
    (r'^static_media/(?P<path>.*)$', 
        'serve', {
        'document_root': '/path/to/static_media',
        'show_indexes': True }),)

your css and jquery on template

<link rel="stylesheet" href="{{ MEDIA_URL }}base_min.css" type="text/css" media="screen">

If your are using production version try this

MEDIA_URL = 'http://media.example.org/'


Development: /static_media/base_min.css
Production: http://media.example.org/base_min.css

Hope this will help you

Don’t forget to attached 'django.contrib.staticfiles', in your INSTALLED_APPS

Leave a comment