Opened 6 years ago

Last modified 2 months ago

#11495 assigned Bug

Improvements to django.views.static.serve directory indexes

Reported by: SmileyChris Owned by: SmileyChris
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 SmileyChris 6 years ago.

Download all attachments as: .zip

Change History (20)

comment:1 Changed 6 years ago by SmileyChris

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to SmileyChris
  • Patch needs improvement unset
  • Status changed from new to assigned

Changed 6 years ago by SmileyChris

comment:2 Changed 6 years ago by gav

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 6 years ago by Alex

  • Triage Stage changed from Unreviewed to Accepted

comment:4 Changed 5 years ago by SmileyChris

  • Triage Stage changed from Accepted to Design 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 4 years ago by jezdez

  • milestone set to 1.3
  • Triage Stage changed from Design decision needed to Accepted

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

comment:6 Changed 4 years ago by ericholscher

  • 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 4 years ago by SmileyChris

  • Summary changed from Small improvements to django.views.static.serve directory indexes to Improvements 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 4 years ago by jezdez

  • milestone 1.3 deleted
  • Triage Stage changed from Accepted to Design 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 4 years ago by SmileyChris

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 4 years ago by julien

  • Severity set to Normal
  • Type set to Cleanup/optimization

comment:11 Changed 3 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:12 Changed 3 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:13 Changed 3 years ago by jezdez

  • Patch needs improvement set

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

comment:14 Changed 3 years ago by SmileyChris

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 2 years ago by aaugustin

What is the use case for this?

comment:16 Changed 2 years ago by ptone

  • Triage Stage changed from Design decision needed to Accepted
  • Type changed from Cleanup/optimization to Bug
  • Version changed from 1.0 to master

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 months ago by collinanderson

  • 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 months ago by timgraham

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 months ago by collinanderson

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

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