Skip to content

Commit

Permalink
Merge pull request #400 from ezarowny/django-4.0
Browse files Browse the repository at this point in the history
Add Django 4.0+ compatibility
  • Loading branch information
bxsx committed Jan 20, 2022
2 parents 77cbffa + 71e5301 commit 968bb51
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 8 deletions.
46 changes: 39 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ jobs:
- TWISTED_VERSION=16.5.0 treq==16.12.0 zope.interface==4.5.0
- TWISTED_VERSION=16.6.0 treq==16.12.0 zope.interface==4.5.0
- TWISTED_VERSION=17.1.0 treq==16.12.0 zope.interface==4.5.0
- DJANGO_VERSION=1.11.20
- DJANGO_VERSION=1.11.29
- DJANGO_VERSION=2.0.13
- DJANGO_VERSION=2.1.7
- DJANGO_VERSION=2.1.15
- DJANGO_VERSION=2.2.26
- DJANGO_VERSION=3.0.14
- DJANGO_VERSION=3.1.14
- DJANGO_VERSION=3.2.11
- DJANGO_VERSION=4.0.1
- PYRAMID_VERSION=1.9.2
- PYRAMID_VERSION=1.10.4
- STARLETTE_VERSION=0.12.12 httpx==0.18.1 python-multipart==0.0.5
Expand All @@ -42,18 +46,46 @@ jobs:
- python-version: 2.7
framework: DJANGO_VERSION=2.0.13
- python-version: 2.7
framework: DJANGO_VERSION=2.1.7
framework: DJANGO_VERSION=2.1.15
- python-version: 2.7
framework: DJANGO_VERSION=2.2.26
- python-version: 2.7
framework: DJANGO_VERSION=3.0.14
- python-version: 2.7
framework: DJANGO_VERSION=3.1.14
- python-version: 2.7
framework: DJANGO_VERSION=3.2.11
- python-version: 2.7
framework: DJANGO_VERSION=4.0.1
- python-version: 3.4
framework: DJANGO_VERSION=2.1.15
- python-version: 3.4
framework: DJANGO_VERSION=2.1.7
framework: DJANGO_VERSION=2.2.26
- python-version: 3.4
framework: DJANGO_VERSION=2.1.15
framework: DJANGO_VERSION=3.0.14
- python-version: 3.4
framework: DJANGO_VERSION=3.1.14
- python-version: 3.4
framework: DJANGO_VERSION=3.2.11
- python-version: 3.4
framework: DJANGO_VERSION=4.0.1
- python-version: 3.5
framework: DJANGO_VERSION=2.1.15
framework: DJANGO_VERSION=3.0.14
- python-version: 3.5
framework: DJANGO_VERSION=3.1.14
- python-version: 3.5
framework: DJANGO_VERSION=3.2.11
- python-version: 3.5
framework: DJANGO_VERSION=4.0.1
- python-version: 3.6
framework: DJANGO_VERSION=2.1.15
framework: DJANGO_VERSION=4.0.1
- python-version: 3.7
framework: DJANGO_VERSION=4.0.1
- python-version: 3.8
framework: DJANGO_VERSION=1.11.29
- python-version: 3.8
framework: DJANGO_VERSION=2.0.13
- python-version: 3.8
framework: DJANGO_VERSION=2.1.15

# twisted/treq setup.py allows:
Expand Down
10 changes: 9 additions & 1 deletion rollbar/contrib/django/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def _patch_debugview(rollbar_web_base):
if new_data in debug.TECHNICAL_500_TEMPLATE:
return
debug.TECHNICAL_500_TEMPLATE = debug.TECHNICAL_500_TEMPLATE.replace(insert_before, replacement, 1)
else:
elif hasattr(debug, 'CURRENT_DIR'):
# patch ExceptionReporter.get_traceback_html if this version of Django is using
# the file system templates rather than the ones in code
# This code comes from:
Expand All @@ -152,6 +152,14 @@ def new_get_traceback_html(exception_reporter):
c = Context(exception_reporter.get_traceback_data(), use_l10n=False)
return t.render(c)
debug.ExceptionReporter.get_traceback_html = new_get_traceback_html
else:
# patch ExceptionReporter.get_traceback_html for Django versions 4.0+
def new_get_traceback_html(self):
"""Return HTML version of debug 500 HTTP error page."""
with self.html_template_path.open(encoding='utf-8') as fh:
t = debug.DEBUG_ENGINE.from_string(fh.read())
c = Context(self.get_traceback_data(), use_l10n=False)
return t.render(c)

if hasattr(debug.ExceptionReporter, '__rollbar__patched'):
return
Expand Down

0 comments on commit 968bb51

Please sign in to comment.