small fixes for django 2.0

This commit is contained in:
2019-03-14 18:41:11 +01:00
parent b12203911e
commit 95f5e0b920
21 changed files with 959 additions and 841 deletions

View File

@@ -3,10 +3,9 @@ between Tags, an at the beginning and the end of the content."""
from django.utils.html import strip_spaces_between_tags
class CompressHtmlMiddleware(object):
class CompressHtmlMiddleware:
"""This Middleware compresses strips the spaces between tags, and at the
beginning and the end of the content."""
# TODO: Port to django 1.10 and upward
def __init__(self, get_response):
"""
@@ -32,7 +31,23 @@ class CompressHtmlMiddleware(object):
response.content).strip()
return response
class SetRemoteAddrFromForwardedFor(object):
class SetRemoteAddrFromForwardedFor:
def __init__(self, get_response):
self.get_response = get_response
# One-time configuration and initialization.
def __call__(self, request):
# Code to be executed for each request before
# the view (and later middleware) are called.
response = self.get_response(request)
# Code to be executed for each request/response after
# the view is called.
return response
def process_request(self, request):
try:
real_ip = request.META['HTTP_X_FORWARDED_FOR']