Static Files - Page Not Found

To see the static files (images and pdf), I defined STATIC_DIRS with values ​​containing the directory names where I load these files:

  STATICFILES_DIRS = (
     '/ home / alessandro / Scrivania / progetto / media / photos / custodia /',
     '/ home / alessandro / Scrivania / progetto / media / definitiva /',
     '/ home / alessandro / Scrivania / progetto / media / proforma /',
     '/ home / alessandro / Scrivania / progetto / media / fpdf /';
 )

In STATIC_URL:

  STATIC_URL = '/ static /' 

In installed applications:

  INSTALLED_APPS = (
    ....

     'django.contrib.staticfiles',

 )

Permissions - 0777.

Now, when I want to see the image or files in pdf format, I get this error message. Page not found

I use this URL:
Http: //127.0.1: 8000 / home / Alessandro / Scrivania / Progetto / media / photo / Custodia / powered_by.png

Any ideas? Why does this problem occur?

+4
source share
1 answer

By default, static and multimedia files are not supported with the built-in Django server. If you want it to serve these files directly, add the staticfiles_urlpatterns and MEDIA_URL in your urlconf.

 from django.conf import settings from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.conf.urls.static import static # ... the rest of your URLconf goes here ... urlpatterns += staticfiles_urlpatterns() urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) 

This will only work if DEBUG is True .

For more information, see the relevant documents .

Note. You must not do this in production! Always use a separate web server for static files in operational mode.

+5
source

All Articles