Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#14507 closed (fixed)

Static file serving is broken after rev 14293

Reported by: mbi Owned by: jezdez
Component: Core (Other) Version: 1.2
Severity: Keywords: static, static_serve
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Revision [14293] committed to fix issue #12323 introduces a bug that prevents static serving if settings.DEBUG is True.

Attachments (1)

14507.diff (620 bytes) - added by mbi 5 years ago.
Patch to fix

Download all attachments as: .zip

Change History (8)

Changed 5 years ago by mbi

Patch to fix

comment:1 Changed 5 years ago by mbi

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 5 years ago by jezdez

  • milestone set to 1.3
  • Owner changed from nobody to jezdez
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 5 years ago by jezdez

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [14306]) Fixed #14507 -- Corrected the logic of the URL helpers and view of staticfiles to actual work like documented (only when settings.DEBUG is True). Thanks for the report and initial patch, mbi.

comment:4 Changed 5 years ago by jnns

  • Resolution fixed deleted
  • Status changed from closed to reopened

I created a Templatetag which renders an AuthenticationForm on every page if the user is not logged in. The form uses context["request"] which is passed to the Templatetag's render() function. When I view the webpage on the development server with settings.DEBUG = False the ImproperlyConfigured exception is not raised as exptected. Instead, all the static files return the following traceback:

Traceback (most recent call last):

  File "/usr/lib/python2.6/dist-packages/django/core/servers/basehttp.py", line 281, in run
    self.result = application(self.environ, self.start_response)

  File "/usr/lib/python2.6/dist-packages/django/contrib/staticfiles/handlers.py", line 57, in __call__
    return self.application(environ, start_response)

  File "/usr/lib/python2.6/dist-packages/django/contrib/staticfiles/handlers.py", line 57, in __call__
    return self.application(environ, start_response)

  File "/usr/lib/python2.6/dist-packages/django/core/handlers/wsgi.py", line 253, in __call__
    response = self.get_response(request)

  File "/usr/lib/python2.6/dist-packages/django/core/handlers/base.py", line 155, in get_response
    return self.handle_uncaught_exception(request, resolver, sys.exc_info())

  File "/usr/lib/python2.6/dist-packages/django/core/handlers/base.py", line 193, in handle_uncaught_exception
    return callback(request, **param_dict)

  File "/usr/lib/python2.6/dist-packages/django/views/defaults.py", line 24, in server_error
    return http.HttpResponseServerError(t.render(Context({})))

  File "/usr/lib/python2.6/dist-packages/django/template/__init__.py", line 173, in render
    return self._render(context)

  File "/usr/lib/python2.6/dist-packages/django/template/__init__.py", line 167, in _render
    return self.nodelist.render(context)

  File "/usr/lib/python2.6/dist-packages/django/template/__init__.py", line 796, in render
    bits.append(self.render_node(node, context))

  File "/usr/lib/python2.6/dist-packages/django/template/__init__.py", line 809, in render_node
    return node.render(context)

  File "/usr/lib/python2.6/dist-packages/django/template/loader_tags.py", line 125, in render
    return compiled_parent._render(context)

  File "/usr/lib/python2.6/dist-packages/django/template/__init__.py", line 167, in _render
    return self.nodelist.render(context)

  File "/usr/lib/python2.6/dist-packages/django/template/__init__.py", line 796, in render
    bits.append(self.render_node(node, context))

  File "/usr/lib/python2.6/dist-packages/django/template/__init__.py", line 809, in render_node
    return node.render(context)

  File "/usr/lib/python2.6/dist-packages/django/template/loader_tags.py", line 62, in render
    result = block.nodelist.render(context)

  File "/usr/lib/python2.6/dist-packages/django/template/__init__.py", line 796, in render
    bits.append(self.render_node(node, context))

  File "/usr/lib/python2.6/dist-packages/django/template/__init__.py", line 809, in render_node
    return node.render(context)

  File "/usr/lib/python2.6/dist-packages/django/template/defaulttags.py", line 258, in render
    return self.nodelist_true.render(context)

  File "/usr/lib/python2.6/dist-packages/django/template/__init__.py", line 796, in render
    bits.append(self.render_node(node, context))

  File "/usr/lib/python2.6/dist-packages/django/template/__init__.py", line 809, in render_node
    return node.render(context)

  File "/usr/lib/python2.6/dist-packages/django/template/defaulttags.py", line 260, in render
    return self.nodelist_false.render(context)

  File "/usr/lib/python2.6/dist-packages/django/template/__init__.py", line 796, in render
    bits.append(self.render_node(node, context))

  File "/usr/lib/python2.6/dist-packages/django/template/__init__.py", line 809, in render_node
    return node.render(context)

  File "/home/jannis/Projekte/[…]/templatetags/loginform.py", line 15, in render
    request = context["request"]

  File "/usr/lib/python2.6/dist-packages/django/template/context.py", line 46, in __getitem__
    raise KeyError(key)

KeyError: 'request'

comment:5 Changed 5 years ago by Honza_Kral

  • Resolution set to fixed
  • Status changed from reopened to closed

please don't reopen unrelated tickets.

The error you are seeing has nothing to do with static files and is not a bug - you are missing debug context_processor and the checks for valid configurations aren't run in production mode.

comment:6 Changed 5 years ago by jnns

I'm sorry for reopening the ticket. It seemed apropriate as this behaviour has nothing to do with a missing context_processor but with this specific commit. All previous commits work fine and following commits cause a KeyError rather than an ImproperlyConfigured Exception which is what this Changeset was about, no?

Sorry again.

comment:7 Changed 4 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

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