GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - heroku-python/dj-static: DEPRECATED - use WhiteNoise instead!

This repository was archived by the owner on May 20, 2021. It is now read-only.
BranchesTags
Open more actions menu

Latest commit

 

History

70 Commits
70 Commits

Folders and files

NameName
Last commit message
Last commit date
LICENSE
LICENSE
 
 
README.rst
README.rst
 
 
dj_static.py
dj_static.py
 
 
setup.py
setup.py
 
 

Repository files navigation

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.

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 Cling

application = 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, MediaCling

application = Cling(MediaCling(get_wsgi_application()))

About

DEPRECATED - use WhiteNoise instead!

kennethreitz.org/introducing-dj-static/

Resources

Readme
BSD-2-Clause license
Activity
Custom properties

Stars

502 stars

Watchers

0 watching

Forks

68 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.