small fixes for django 2.0
This commit is contained in:
@@ -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']
|
||||
|
||||
Reference in New Issue
Block a user