Opened 8 years ago
Last modified 8 years ago
#29353 closed Bug
_middleware_chain is not set for StaticFilesHandler — at Version 3
| Reported by: | koxu1996 | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.staticfiles | Version: | 2.0 |
| Severity: | Normal | Keywords: | staticfiles middleware_chain |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I created functional_tests directory with empty init.py and test_all.py containing following code:
from django.test import LiveServerTestCase
from selenium import webdriver
class DemoTest(LiveServerTestCase):
def test_can_get_empty_list_of_server_seeds(self):
self.browser = webdriver.Firefox()
print('Before page open')
self.browser.get(self.live_server_url + '/')
print('After page open')
self.assertEqual(1, 1)
self.browser.quit()
Running it with 'python manage.py test functional_tests/' result with success:
... Before page open After page open . ---------------------------------------------------------------------- Ran 1 test in 7.048s OK ...
But if I change LiveServerTestCase to StaticLiveServerTestCase then I am getting strange error:
$ python manage.py test functional_tests/
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
Before page open
Traceback (most recent call last):
File "/usr/lib/python3.6/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/usr/lib/python3.6/site-packages/django/contrib/staticfiles/handlers.py", line 67, in __call__
return super().__call__(environ, start_response)
File "/usr/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 146, in __call__
response = self.get_response(request)
File "/usr/lib/python3.6/site-packages/django/contrib/staticfiles/handlers.py", line 62, in get_response
return super().get_response(request)
File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py", line 81, in get_response
response = self._middleware_chain(request)
TypeError: 'NoneType' object is not callable
Traceback (most recent call last):
File "/usr/lib/python3.6/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/usr/lib/python3.6/site-packages/django/contrib/staticfiles/handlers.py", line 67, in __call__
return super().__call__(environ, start_response)
File "/usr/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 146, in __call__
response = self.get_response(request)
File "/usr/lib/python3.6/site-packages/django/contrib/staticfiles/handlers.py", line 62, in get_response
return super().get_response(request)
File "/usr/lib/python3.6/site-packages/django/core/handlers/base.py", line 81, in get_response
response = self._middleware_chain(request)
TypeError: 'NoneType' object is not callable
After page open
.
----------------------------------------------------------------------
Ran 1 test in 6.659s
OK
Destroying test database for alias 'default'...
Change History (4)
follow-up: 2 comment:1 by , 8 years ago
by , 8 years ago
| Attachment: | issue.tar.gz added |
|---|
comment:2 by , 8 years ago
Replying to Tim Graham:
Can you please debug the issue and explain why Django is at fault? Or at least provide a sample project that reproduces the problem. I can't reproduce a problem given the information you provided.
I added attachment with sample project.
comment:3 by , 8 years ago
| Component: | Uncategorized → contrib.staticfiles |
|---|---|
| Description: | modified (diff) |
| Keywords: | staticfiles middleware_chain added; static-files testing server removed |
| Summary: | Static files path cannot be the same as directory name? → _middleware_chain is not set for StaticFilesHandler |
Can you please debug the issue and explain why Django is at fault? Or at least provide a sample project that reproduces the problem. I can't reproduce a problem given the information you provided.