Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/heroku-python/dj-static
DEPRECATED - use WhiteNoise instead!
https://github.com/heroku-python/dj-static
Last synced: 2 months ago
JSON representation
DEPRECATED - use WhiteNoise instead!
- Host: GitHub
- URL: https://github.com/heroku-python/dj-static
- Owner: heroku-python
- License: bsd-2-clause
- Archived: true
- Created: 2013-07-12T21:04:59.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-09-30T12:30:46.000Z (over 7 years ago)
- Last Synced: 2024-11-07T23:46:58.534Z (2 months ago)
- Language: Python
- Homepage: http://kennethreitz.org/introducing-dj-static/
- Size: 28.3 KB
- Stars: 512
- Watchers: 27
- Forks: 71
- Open Issues: 8
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
- starred-awesome - dj-static - Serve production static files with Django. (Python)
README
DJ-Static
=========This is a simple Django middleware utility that allows you to properly
serve static assets from production with a WSGI server like Gunicorn... note:: You should probably use `WhiteNoise `_ instead. It's better software.
Django `doesn't recommend `_
the production use of its static file server for a number of reasons.
There exists, however, a lovely WSGI application aptly named `Static `_... image:: http://farm8.staticflickr.com/7387/8907351990_58677d7c35_z.jpg
"Finally, a super-simple way of serving assets in Django that’ll actually perform well" — `@jacobian `_
It is suitable for the production use of static file serving, unlike Django.
Enjoy!Shouldn't I use a CDN?
----------------------If you have to ask that question, there's actually quite a good chance you don't.
Static responses aren't very different than dynamic ones.If you're running a top-tier application, optimizing for delivery and reducing
frontend load, you will want to explore using a CDN with
`Django-Storages `_.Usage
-----::
$ pip install dj-static
Configure your static assets in ``settings.py``::
STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'Then, update your ``wsgi.py`` file to use dj-static::
from django.core.wsgi import get_wsgi_application
from dj_static import Clingapplication = Cling(get_wsgi_application())
File uploads (optional)
^^^^^^^^^^^^^^^^^^^^^^^In case you also want to serve media files that were uploaded to ``MEDIA_ROOT``::
MEDIA_ROOT = 'media'
MEDIA_URL = '/media/'Then again, update your ``wsgi.py`` file::
from django.core.wsgi import get_wsgi_application
from dj_static import Cling, MediaClingapplication = Cling(MediaCling(get_wsgi_application()))