Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Middleware compatibility with Django 1.10 #853

Closed
valignatev opened this issue Jul 20, 2016 · 13 comments
Closed

Middleware compatibility with Django 1.10 #853

valignatev opened this issue Jul 20, 2016 · 13 comments
Labels

Comments

@valignatev
Copy link
Contributor

Since Django 1.10 introduced new middleware style, existing middlewares should be updated. For now I can suggest possible workaround for impatient Django 1.10 users:

from django.utils.deprecation import MiddlewareMixin
from debug_toolbar.middleware import DebugToolbarMiddleware


class AtopdedTo110DebugMiddleware(MiddlewareMixin, DebugToolbarMiddleware):
    pass

And then add it to your MIDDLEWARE settings:

MIDDLEWARE += ['my.middleware.AtopdedTo110DebugMiddleware']

@SalahAdDin
Copy link

SalahAdDin commented Aug 2, 2016

I found this issue related:

./manage.py runserver                                                                                                    ✓  1712  02:49:41 
/home/salahaddin/Proyectos/makeintegrity/lib/python3.5/site-packages/debug_toolbar/settings.py:189: Warning: Please use an explicit setup with the debug_toolbar.middleware.DebugToolbarMiddleware after django.middleware.gzip.GZipMiddlware in MIDDLEWARE_CLASSES.
  "in MIDDLEWARE_CLASSES.", Warning)
/home/salahaddin/Proyectos/makeintegrity/lib/python3.5/site-packages/debug_toolbar/settings.py:189: Warning: Please use an explicit setup with the debug_toolbar.middleware.DebugToolbarMiddleware after django.middleware.gzip.GZipMiddlware in MIDDLEWARE_CLASSES.
  "in MIDDLEWARE_CLASSES.", Warning)
Performing system checks...

I'd maked automatic install.

@valignatev
Copy link
Contributor Author

@SalahAdDin It is not really related. The fact that debug middleware should be placed after GZipMiddlware is I think in first page of docs in big Note section: https://django-debug-toolbar.readthedocs.io/en/stable/installation.html

@SalahAdDin
Copy link

SalahAdDin commented Aug 2, 2016

Automatic installation install all if i don't want install manually.

Oh, i understand you.

metalpriest pushed a commit to metalpriest/django-debug-toolbar that referenced this issue Aug 4, 2016
@SalahAdDin
Copy link

I can verify that this issue disable the debug toolbar button, i have to comment the gzip middle ware for enable these button again.

@cdman
Copy link

cdman commented Aug 12, 2016

@valentjedi - thank you for the workaround!

Related: the documentation should also be updated: https://django-debug-toolbar.readthedocs.io/en/stable/installation.html#middleware

@AlJohri
Copy link

AlJohri commented Sep 26, 2016

any chance you can push a new release with this fix?

@sandroden
Copy link

Hi, sorry if adding a comment on a closed ticket. the proposed solutions works for me only with python2.7. Whe in Python3.5 i get the following error:


  File "<frozen importlib._bootstrap_external>", line 662, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/home/misc/src/hg/thunder/jmb2/sd/3p/marketest/web/middleware.py", line 7, in <module>
    class AtopdedTo110DebugMiddleware(MiddlewareMixin, DebugToolbarMiddleware):
TypeError: Cannot create a consistent method resolution
order (MRO) for bases DebugToolbarMiddleware, MiddlewareMixin
sandro@bluff:/misc/src/hg/thunder/jmb2/sd/art/marketest$ e /home/misc/src/hg/thunder/jmb2/sd/3p/marketest/web/middleware.py

sandro
*:-)

ryneeverett pushed a commit to ryneeverett/django-debug-toolbar that referenced this issue Oct 2, 2016
@valignatev
Copy link
Contributor Author

@sandroden
This thing is in PyPI now as I understand so you just use regular DebugToolbarMiddleware and all will be fine

@SalahAdDin
Copy link

SalahAdDin commented Oct 9, 2016

Is current PYPI package version the new version?

@valignatev
Copy link
Contributor Author

Yes AFAIK. Anyway, in my current setup (django 1.10.2 and debug-toolbar 1.6) I just remove this workaround and add 'debug_toolbar.middleware.DebugToolbarMiddleware' to my MIDDLEWARE list. All works. And this fix already in code base.

@aaugustin
Copy link
Contributor

Yes I pushed a release with the updated middleware this week.

@darkpixel
Copy link

I'm not seeing the update on pypi. Is only on github?

23:09:49 [aaron@ender:~/code/intranet] [intranet] develop(+10/-17)+* ± pip freeze | egrep Django|debug'
Django==1.10.4
django-debug-toolbar==1.6                                                                                                                                     
23:12:09 [aaron@ender:~/code/intranet] [intranet] develop(+10/-39)+* ± pip install --upgrade django-debug-toolbar
Requirement already up-to-date: django-debug-toolbar in /home/aaron/.virtualenvs/intranet/lib/python3.5/site-packages
Cleaning up...
23:12:25 [aaron@ender:~/code/intranet] [intranet] develop(+10/-39)+* ± 

@darkpixel
Copy link

Ignore my previous comment. I missed the Python 3.5 pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants