Opened 6 years ago

Closed 6 years ago

#17689 closed Bug (fixed)

CachedFilesMixin causes ValueError when provided with a path to url()

Reported by: tkaemming Owned by: nobody
Component: contrib.staticfiles Version: 1.4-alpha-1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


For example, trying to set window.__admin_media_prefix__ in admin/base.html causes this error.

Here's the offending template tag:

Traceback (I cut out the render bits and only left the parts significant to the issue at hand):

[pid: 23479|app: 0|req: 2/11] () {40 vars in 780 bytes} [Tue Feb 14 19:42:53 2012] GET /admin/ => generated 168 bytes in 430 msecs (HTTP/1.0 500) 4 headers in 174 bytes (1 switches on core 0)
Internal Server Error: /admin/
Traceback (most recent call last):
  File "/srv/versions/development/src/django/django/contrib/staticfiles/templatetags/", line 13, in static
    return staticfiles_storage.url(path)
  File "/srv/versions/development/src/django/django/contrib/staticfiles/", line 111, in url
    hashed_name = self.hashed_name(clean_name).replace('\\', '/')
  File "/srv/versions/development/src/django/django/contrib/staticfiles/", line 74, in hashed_name
    (clean_name, self))
ValueError: The file 'admin/' could not be found with < object at 0x8ce99cc>.

I've attached a patch that prevents CachedStaticMixin from attempting to hash names ending in a path separator (forward slash only), incl. tests.

Attachments (1)

ticket-17689.diff (2.2 KB) - added by tkaemming 6 years ago.

Download all attachments as: .zip

Change History (3)

Changed 6 years ago by tkaemming

Attachment: ticket-17689.diff added

comment:1 Changed 6 years ago by tkaemming

Version: 1.31.4-alpha-1

comment:2 Changed 6 years ago by Jannis Leidel

Resolution: fixed
Status: newclosed

In [17535]:

Fixed #17689 -- Stopped the CachedStaticFilesStorage from trying to hash paths that aren't files.

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