Code

Opened 7 years ago

Closed 6 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:

Description

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.

Usage:
if serve_static:

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

Attachments (1)

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

Download all attachments as: .zip

Change History (7)

Changed 7 years ago by mgiger@…

comment:1 Changed 7 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 7 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 7 years ago by SmileyChris

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

comment:4 Changed 7 years ago by SmileyChris

  • Needs documentation set

comment:5 Changed 7 years ago by PhiR

  • Keywords file, feature added; file removed

comment:6 Changed 6 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.