Static Files won't show with Django

django static files not found in production
django static files production
django static files not working
django static files 404
django static files tutorial
django not serving static files
django gunicorn static files
django nginx static files
<!DOCTYPE html>
{% load staticfiles %}
<html>
........
<img src="{% static 'images/parralax/spaces.jpg' %}"  width = 250px  />
<body>

Above code won't show the image I have as a background. Really unsure how to fix this issue.

Here are my setting files. I think the issue is coming from linking to CSS not working. Thanks in advance!

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates')
STATIC_DIR = os.path.join(BASE_DIR, 'static')
MEDIA_DIR = os.path.join(BASE_DIR,'media')


TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [TEMPLATE_DIR,],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [.....
            ],
        },
    },
]

STATICFILES_DIRS = [STATIC_DIR,  ]
STATIC_URL = '/static/'
MEDIA_ROOT = MEDIA_DIR #where to look for files
MEDIA_URL = '/media/' #where to serve files from on url
WSGI_APPLICATION = 'Space.wsgi.application'
STATIC_ROOT = os.path.join(BASE_DIR, 'static_root')

.....


.....
urls.py
urlpatterns = [
    url(r'^$', views.index, name='index'),
    url(r'^Spaces/', include('Spaces.urls')),
    #Django Admin
    path('admin/', admin.site.urls),
    #User Management
    url(r'^accounts/', include('allauth.urls')),
    path(r'^users/', include('users.urls')),
    path(r'^users/', include('django.contrib.auth.urls')),
]

urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_DIR)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_DIR)

Please help :)

Cheers!

Be sure you write this line top of your html file:

{% load static %}

second point is close your div with :

</div>

and write something into div or provide a 'height' attribute for your dive:

<div class="full-screen force-full-screen" style="background: url('{% static 'images/parallax/home/9.jpg' %}') center center no-repeat; background-size: cover;height: 100px;">

third point : be sure this two line is in your settings.py:

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

Hope this helps.

Deploying static files | Django documentation, Since your static file server won't be running Django, you'll need to modify the deployment strategy to look something like: When your static files change, run  django cached static_root static_url settings.py won't reflect the change I made in file. – eugene Jan 30 '13 at 7:15 7 python manage.py findstatic renders Error: Enter at least one static file. – antonagestam May 3 '13 at 13:59

use

{% load static from staticfiles %}

Managing static files (e.g. images, JavaScript, CSS), staticfiles to help you manage them. This page describes how you can serve these static files. Configuring static files¶. Make sure that django.contrib  Non-standard content types. Static File Middleware understands almost 400 known file content types. If the user requests a file with an unknown file type, Static File Middleware passes the request to the next middleware in the pipeline. If no middleware handles the request, a 404 Not Found response is returned.

Use {% load static %} at the start of your HTML files(except for base.html) instead of {% load staticfiles %}.

And make sure this is available in your settings.py

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

Static Files Won't Serve · Issue #248 · tomturner/django-tenants , Static files gets copied to my_proj_path/staticfiles/tenant1 but logging into the admin via the frontend still yields 404 with css/js files. within the  You need to define a static root (which will be empty to begin with) and run the manage.py collectstatic command to move the static files from throughout your project into that folder. Then you can serve them from there.

I fixed this issue.

I was linking the wrong folder the entire time. Silly mistake.

Thanks everyone for your help :)

Managing static files (e.g. images, JavaScript, CSS), The style won't change, so it's a static file rather than a template. Flask automatically adds a static view that takes a path relative to the flaskr/static directory and  Your problem is that you arent listening to the URL “/static/” nowhere in your urls.py. If you serve your application via a webserver like apache or nginx then this is normal as the webserver would handle the static files itself. For development Django comes with a built-in static server. to urls.py, at the very end add

ExpressJS - Serving static files, Django won't automatically create the target directory ( STATIC_ROOT ) that collectstatic uses, if it isn't available. You may need to create this  CSS, JavaScript, or other static files not loading? Hopefully this guide can help. First, have you actually set up your static files on the Web tab? See this general guide to static files or this specific guide to static files in Django. If yes: examine a specific example. Let's start with a specific example of a static file that's not working.

How to make Django serve static files with Gunicorn?, Since your static file server won't be running Django, you'll need to modify the to look something like: When your static files change, run collectstatic locally. 1. Static Files. A static file is a file that does not contain any front matter. These include images, PDFs, and other un-rendered content.

Django admin not serving static files?, Now, if you are run the server and visit the localhost, you won't see the styling, but why? That's because static assets must be loaded explicitly in the templates. However, if the shared library is not present on the UNIX file system, or the shared library is present, but not the right version, the dynamic UNIX program won't run. On the UNIX command line, you can determine whether any executable file is built with static or dynamic libraries. Use this command: file . For example: % file payconfig.cgi

Comments
  • {% static 'images/parallax/home/9.jpg' %} what url does it produce? Which response do you get when opening this url?
  • Page not found (404) Request URL: 127.0.0.1:8000/Spaces/images/parallax/home/9.jpg
  • What are STATICFILES_DIRS, STATIC_URL values? Did you run collectstatic?
  • Given config would result in 127.0.0.1:8000/static/images/parallax/home/9.jpg because of static function usage and STATIC_URL = '/static/' value. And I assume you did not run collectstatic and you're trying to reach image located inside Spaces app subfolders. Is this correct?
  • Are you running with DEBUG = True or DEBUG = False?