6๐
โ
As per the documentation:
This helper function works only in debug mode and only if the given
prefix is local (e.g. /media/) and not a URL (e.g.
http://media.example.com/).
With the helper function they mention being: + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Setting up static & media files for nginx in production very simple, DigitalOcean has a great guide. The Static part is just a couple lines:
location /media/ {
root /home/sammy/myproject;
}
๐คJens Astrup
0๐
Set this code below to "urls.py" to show media files in "DEBUG = False":
# "urls.py"
from django.conf.urls import url
from django.views.static import serve
from django.conf import settings
urlpatterns = [
# ...
url(r'^media/(?P<path>.*)$', serve,{'document_root': settings.MEDIA_ROOT}),
]
- [Django]-Django with django-nose: two identical settings files with different behavior in running test command
- [Django]-Asterisk in django forms validation messages
- [Django]-Django forms client side validation?
Source:stackexchange.com