Opened 7 years ago

Closed 19 months ago

#11495 closed Bug (wontfix)

Improvements to django.views.static.serve directory indexes

Reported by: Chris Beaven Owned by: Chris Beaven
Component: Core (Other) Version: master
Severity: Normal Keywords: static
Cc: cmawebsite@… Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

This patch sorts indexes and shows directories before files.
It also adds functionality for providing an index prefix so the template can show the full indexed path correctly.

Attachments (1)

11495.diff (3.4 KB) - added by Chris Beaven 7 years ago.

Download all attachments as: .zip

Change History (21)

comment:1 Changed 7 years ago by Chris Beaven

Owner: changed from nobody to Chris Beaven
Status: newassigned

Changed 7 years ago by Chris Beaven

Attachment: 11495.diff added

comment:2 Changed 7 years ago by George Vilches

Being that the way a directory is sorted is an OS-specific choice, with *nix users getting solidly alphabetic sorting, and Windows users getting folder then file sorting, this should be an either/or option, not a unilateral change.

comment:3 Changed 7 years ago by Alex Gaynor

Triage Stage: UnreviewedAccepted

comment:4 Changed 7 years ago by Chris Beaven

Triage Stage: AcceptedDesign decision needed

My view is that it should be consistent no matter what OS is running the server. But pushing do a design decision.

comment:5 Changed 6 years ago by Jannis Leidel

milestone: 1.3
Triage Stage: Design decision neededAccepted

I agree with SmileyChris, this should be made consistent across the different OSs.

comment:6 Changed 6 years ago by Eric Holscher

Needs documentation: set
Needs tests: set

Seems like a good idea. However the new prefix needs to be documented, and this is a good candidate for testing, especially because it might vary across platforms.

comment:7 Changed 6 years ago by Chris Beaven

Summary: Small improvements to django.views.static.serve directory indexesImprovements to django.views.static.serve directory indexes

I've redone this for static-file awareness, patch can be found here:

https://github.com/SmileyChris/django/compare/master...11495-static-directory-indexes

comment:8 Changed 6 years ago by Jannis Leidel

milestone: 1.3
Triage Stage: AcceptedDesign decision needed

Hm, that branch goes a bit further than the ticket suggested, also listing all files/folders that the staticfiles finders find. IMO requires more discussion on -dev list.

comment:9 Changed 6 years ago by Chris Beaven

It does, since how indexes currently work with staticfiles now doesn't make a whole lot of sense.

I'm in agreement that it definitely requires more discussion.

comment:10 Changed 6 years ago by Julien Phalip

Severity: Normal
Type: Cleanup/optimization

comment:11 Changed 5 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:12 Changed 5 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:13 Changed 4 years ago by Jannis Leidel

Patch needs improvement: set

The branch isn't there anymore, any chance to update the patch here?

comment:14 Changed 4 years ago by Chris Beaven

I haven't looked at updating the branch, but it can be found here now (tied to the old django/django github repo):

https://github.com/SmileyChris/django-old/compare/master...11495-static-directory-indexes

comment:15 Changed 4 years ago by Aymeric Augustin

What is the use case for this?

comment:16 Changed 4 years ago by Preston Holmes

Triage Stage: Design decision neededAccepted
Type: Cleanup/optimizationBug
Version: 1.0master

Why should views.static.serve consider static file finders? As documented it is just a directory based tool.

I'd move to splitting this into two tickets. Accept this one which has the narrow scope of standardizing the sort order across OS versions for basic static.serve, I think this isn't too contentious.

The issue of how to incorporate static-file finders into index display can be sorted out separately, with its rationale and design proposal.

comment:17 Changed 2 years ago by Collin Anderson

Cc: cmawebsite@… added
Keywords: static added

I think we should deprecate and remove show_indexes completely. What do people use it for?

comment:18 Changed 2 years ago by Tim Graham

It seems show_indexes dates back to when the view was first added in 572ac3e7dfadec6434527ebbdccef97de1cc191c. I didn't see any mention in the ticket about why this functionality was needed. I guess it makes it a bit easier to debug if you have a typo in a file name or something (rather than opening up a file browser). Collin, can you present your rationale for deprecating it? No doubt some people like it and use it.

comment:19 Changed 2 years ago by Collin Anderson

My goal would be to start fully supporting using static.serve() (or something like it) in production (in 1.9), but we wouldn't want to support show_indexes in production.

Also, as mentioned, now that we have the staticfiles framework, this little feature is a lot harder to get right.

It seems to me, if you want a web index of files, you could just run python3 -m http.server 8080.

There's also this django-developers discussion: https://groups.google.com/d/topic/django-developers/N0KbgDeLuUE/discussion

comment:20 Changed 19 months ago by Tim Graham

Resolution: wontfix
Status: assignedclosed
Note: See TracTickets for help on using tickets.
Back to Top