Opened 8 years ago

Closed 8 years ago

#5157 closed (wontfix)

Direct Apache to serve a static file from view code

Reported by: mgiger@… Owned by: nobody
Component: Core (Other) Version: master
Severity: Keywords: apache, static file, feature
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: no
Easy pickings: UI/UX:


Django is not meant to be a static file server, but there is no easy method to direct Apache to serve a file. I have a use case where I need to authenticate a user and decide which static media file to pass back based on some model and view logic.

if serve_static:

raise http.HttpInternalRedirect('/path/to/file/')

Attachments (1)

apache_redirect.diff (2.1 KB) - added by mgiger@… 8 years ago.

Download all attachments as: .zip

Change History (7)

Changed 8 years ago by mgiger@…

comment:1 Changed 8 years ago by SmileyChris

  • Triage Stage changed from Unreviewed to Design decision needed

Very cool! Could you please bring this up in the Django Developers group to get some feedback?

comment:2 Changed 8 years ago by ubernostrum

What would this gain over having a view decide whether to serve the file or not, and then returning django.views.static.serve with appropriate arguments?

comment:3 Changed 8 years ago by SmileyChris

The fact it doesn't have to feed the file through the Python interpreter.

comment:4 Changed 8 years ago by SmileyChris

  • Needs documentation set

comment:5 Changed 8 years ago by PhiR

  • Keywords feature added

comment:6 Changed 8 years ago by jacob

  • Resolution set to wontfix
  • Status changed from new to closed

This is too tightly coupled to mod_python for general inclusion. It's a good candidate for third-party exception middleware.

Note: See TracTickets for help on using tickets.
Back to Top