15👍
✅
I just figured this out after posting…
If you’re using django-admin.py runserver
or python manage.py runserver
, then it does some extra magic to add a staticfiles handler that your regular middleware can’t touch.
You can disable this by running django-admin.py runserver --nostatic
— see the django docs
And when you do --nostatic
it will fall back to the urls in your app, such as if you include staticfiles_urls() directly with:
urlpatterns += staticfiles_urlpatterns()
then your middleware will run for those urls (and of course all your others).
1👍
Found this issue when trying to modify request.path with middleware.
Discovered urls resolve against request.path_info
not request.path
👤Doug
- Django-allauth: Only allow users from a specific google apps domain
- Django : Syncdb incorrectly warns that many-to-many field is stale
- Why is gunicorn_django not recommended anymore?
- HttpResponseRedirect after login form not redirecting to profile
Source:stackexchange.com