Opened 13 years ago

Closed 13 years ago

#16629 closed Bug (fixed)

STATIC_ROOT should not be required by {% static %} when using development server

Reported by: Ben Davis Owned by: nobody
Component: contrib.staticfiles Version: dev
Severity: Normal Keywords:
Cc: bendavis78@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The development server uses its own views for serving static files directly, instead of from STATIC_ROOT, so the STATIC_ROOT setting should not be required under a development environment. One can normally get by without STATIC_ROOT as long as STATIC_URL is used. However, when using the {% static %} template tag, the following exception is raised:

Caught ImproperlyConfigured while rendering: You're using the staticfiles app without having set the STATIC_ROOT setting

Full traceback:

File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/core/handlers/base.py" in get_response
  136.                     response = response.render()
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/template/response.py" in render
  112.             self._set_content(self.rendered_content)
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/template/response.py" in rendered_content
  89.         content = template.render(context)
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/template/base.py" in render
  122.             return self._render(context)
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/template/base.py" in _render
  116.         return self.nodelist.render(context)
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/template/base.py" in render
  745.                 bits.append(self.render_node(node, context))
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/template/debug.py" in render_node
  72.             result = node.render(context)
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/template/loader_tags.py" in render
  125.         return compiled_parent._render(context)
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/template/base.py" in _render
  116.         return self.nodelist.render(context)
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/template/base.py" in render
  745.                 bits.append(self.render_node(node, context))
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/template/debug.py" in render_node
  72.             result = node.render(context)
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/template/loader_tags.py" in render
  125.         return compiled_parent._render(context)
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/template/base.py" in _render
  116.         return self.nodelist.render(context)
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/template/base.py" in render
  745.                 bits.append(self.render_node(node, context))
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/template/debug.py" in render_node
  72.             result = node.render(context)
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/template/loader_tags.py" in render
  62.             result = block.nodelist.render(context)
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/template/base.py" in render
  745.                 bits.append(self.render_node(node, context))
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/template/debug.py" in render_node
  72.             result = node.render(context)
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/template/base.py" in render
  886.                     return func(*func_args)
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/contrib/staticfiles/templatetags/staticfiles.py" in static
  13.     return staticfiles_storage.url(path)
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/utils/functional.py" in inner
  172.             self._setup()
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/contrib/staticfiles/storage.py" in _setup
  205.         self._wrapped = get_storage_class(settings.STATICFILES_STORAGE)()
File "/home/ben/Projects/SavidWorks/.testenv/src/django/django/contrib/staticfiles/storage.py" in __init__
  34.             raise ImproperlyConfigured("You're using the staticfiles app "

Exception Type: TemplateSyntaxError at /admin/
Exception Value: Caught ImproperlyConfigured while rendering: You're using the staticfiles app without having set the STATIC_ROOT setting.

Change History (1)

comment:1 by Jannis Leidel, 13 years ago

Resolution: fixed
Status: newclosed

In [16617]:

Fixed #16629 -- Relaxed check for STATIC_ROOT and STATIC_URL settings slightly to only raise an exception if really needed.

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