DjangoIntegration conflict with MiddlewareMixin & TemplateView
See original GitHub issuedjango version: 3.0 sentry-sdk version: 0.14.3
My project has a middleware using Django’s django.utils.deprecation.MiddlewareMixin
. Visiting a view which subclasses django.views.generic.TemplateView
while Sentry is active results in the following exception:
AttributeError: 'function' object has no attribute '__self__'
File "django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "django/core/handlers/base.py", line 196, in _get_response
middleware_method.__self__.__class__.__name__,
The following classes & url config should be sufficient to demonstrate the problem:
from django.utils.deprecation import MiddlewareMixin
from django.views.generic import TemplateView
# ...in myapp.middleware.py
class DemonstratesConflictMiddleware(MiddlewareMixin):
def process_template_response(self, request, response):
return response
# ...in myapp.views.py
class DemonstratesConflictView(TemplateView):
template_name = "index.html"
# ...in urls.py
import myapp.views
urlpatterns += [
path('/', myapp.views.DemonstratesConflictView.as_view(), name='throws-exception'),
]
# ... in settings.py
MIDDLEWARE += ['myapp.middleware.DemonstratesConflictMiddleware']
sentry_sdk.init(
dsn="OMITTED",
integrations=[DjangoIntegration()],
)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Django "TemplateView" and "/media/" url conflict
is messing up media url, and files uploaded by user cannot be reached by url link, even though they are saved to folder,...
Read more >Using mixins with class-based views - Django documentation
... and methods are likely to cause conflict between different classes and mixins. ... For example it's fine to combine TemplateView (built in...
Read more >Django - Sentry Documentation
Sentry's Django integration reports all exceptions leading to an Internal Server Error and creates a separate scope for each request.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
0.16.3 is out which fixes the problem.
This issue was resolved for me upgrading to 1.5.4 (I had 0.15 before)