error message must accept None, so %d->%s
[wolnelektury.git] / lib / realip_middleware.py
1 class SetRemoteAddrFromXRealIP(object):
2     """Sets REMOTE_ADDR from the X-Real-IP header, as set by Nginx."""
3     def process_request(self, request):
4         try:
5             request.META['REMOTE_ADDR'] = request.META['HTTP_X_REAL_IP']
6         except KeyError:
7             return None