D
D
Dmitry Vyatkin2016-01-20 04:01:38
Python
Dmitry Vyatkin, 2016-01-20 04:01:38

How to distribute media files in django?

Goodnight! I can NOT display files from the media folder with DEBUG=True, while files from static work fine. Please tell me what could be the problem!?

MEDIA_ROOT = os.path.join(BASE_DIR, "files", "media")

MEDIA_URL = "/files/media/"

STATIC_ROOT = os.path.join(BASE_DIR, "files", "static")

STATIC_URL = "/files/static/"

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "templates", "static"),
]

STATICFILES_FINDERS = [
    "django.contrib.staticfiles.finders.FileSystemFinder",
    "django.contrib.staticfiles.finders.AppDirectoriesFinder",
]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nerevar_soul, 2016-01-20
@Nerevar_soul

urlpatterns = patterns('',
# ... the rest of your URLconf goes here ...
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
more here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question