Every web developer and programmer said that if you are working on Django project never serve your static and media files using Django on the production environment, always use webserver like Apache or Nginx to serve these files. Actually I get so many references from the internet that how to server static and media files using Django in production but on the other hand, they said that never serve static and media content with Django because it is inefficient and probably insecure. Why Django is not best for serving static and media content in production. Why serve static and media content with webservers.
2 Answers
The simple answer to your question is that because Django's main role is not for serving static/media files. Yes they are so nice and they already include a small part for behaving like a web server but it's definitely not like a reverse proxy such as Apache or Ngnix.
What additional power you get with Apache or Ngnix is that they are production-ready servers so that they can server much more requests in a more secure and robust way than Django's own server component.
But for small project for your own, you can surely use Django for all and not needing an actual reverse proxy service

- 178
- 1
- 8
-
Never use runserver in production, you always need uwsgi or some kind of wsgi fully audited secure server – iklinac Jul 15 '20 at 13:09
Django runserver is not meant to be used in production as documented
DO NOT USE THIS SERVER IN A PRODUCTION SETTING. It has not gone through security audits or performance tests. (And that’s how it’s gonna stay. We’re in the business of making Web frameworks, not Web servers, so improving this server to be able to handle a production environment is outside the scope of Django.)
Normally you would use wsgi server like uwsgi to host python applications and if you look in documentation you would notice that they suggest using nginix to host static files efficiently with hint of choosing different server for performance reasons and you have also more options of customizing where to host them by having nginx in front ( same server/different server/multiple servers etc.)
Also django docs regarding deploying static files

- 14,944
- 4
- 28
- 30