Skip to content

Commit 39555c7

Browse files
author
Christo Goosen
committed
Fix code to support django4 and up, edge case for code older than 3.2
1 parent 6555e4a commit 39555c7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

maintenancemode/middleware.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ def process_request(self, request):
5151
return None
5252
# Otherwise show the user the 503 page
5353

54-
if DJANGO_VERSION_MAJOR >= 3 and DJANGO_VERSION_MINOR >= 2:
55-
# Checks if DJANGO version is great than 3.2.0 for breaking change
56-
resolver = resolvers.get_resolver(None)
57-
resolve = resolver.resolve_error_handler
58-
callback = resolve('503')
59-
60-
return callback(request)
61-
else:
54+
if (DJANGO_VERSION_MAJOR == 3 and DJANGO_VERSION_MINOR <= 2) or DJANGO_VERSION_MAJOR < 3:
55+
# Checks if DJANGO version is less than 3.2.0 for breaking change
6256
resolver = get_resolver()
6357

6458
callback, param_dict = resolver.resolve_error_handler("503")
6559

6660
return callback(request, **param_dict)
6761

62+
else:
63+
# Default behaviour for django 3.2 and higher
64+
resolver = resolvers.get_resolver(None)
65+
resolve = resolver.resolve_error_handler
66+
callback = resolve('503')
6867

68+
return callback(request)
6969

0 commit comments

Comments
 (0)