I'm writing a Django app in which the users can upload images, and I'm not sure how to serve them. I can see two ways:
1- upload them as static files: upload them in the static
folder in my project's directory, and then run python manage.py collectstatic
, but I don't know how to run this command automatically every time a file is uploaded, and this seems to be a lot of processing because every time the server will delete and reload everything in my static app.
2- use django.views.static.serve
in my urls.py:
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT,
}),
but the doc does not recommend it for production.
What's the recommended way to serve user-uploaded files?