Search code examples
pythondjangodjango-viewsstatic-files

Django: Static content on very small scale website


I'm working on a very small scale website for my school (less than 100 users a day) and was wondering if there was a way too store static files on the django server instead of deploying a second server to manage static files. Google searches turn up things like the following: https://docs.djangoproject.com/en/dev/howto/static-files/, but I'm wondering if there was a more simple way to do this, even if it wasn't very efficient, on the Django server.


Solution

  • Yes it's certainly possible to serve the static files using the same server. The doc give an example of doing this using Apache/mod_wsgi https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/#serving-files

    If, however, you have no option but to serve media files on the same Apache VirtualHost as Django, you can set up Apache to serve some URLs as static media, and others using the mod_wsgi interface to Django.

    It's worth noting that when the docs reference using a separate web server it does not necessarily mean another box (virtual or physical) just a separate server optimized for serving static resources. From https://docs.djangoproject.com/en/1.4/howto/static-files/#serving-static-files-from-a-dedicated-server

    Most larger Django apps use a separate Web server -- i.e., one that's not also running Django -- for serving static files. This server often runs a different type of web server -- faster but less full-featured.

    A common setup would be to run Nginx for static resources in front of Apache/mod_wsgi, Gunicorn or uWSGI as the WSGI server which for a small site could be done on a single server.