selwin / django-user_agents

A django package that allows easy identification of visitor's browser, OS and device information, including whether the visitor uses a mobile phone, tablet or a touch capable device.
MIT License
640 stars 104 forks source link

Django 1.11 issue #20

Closed zavod closed 7 years ago

zavod commented 7 years ago

It's error with Django 1.11 mw_instance = middleware(handler) TypeError: object() takes no parameters

bradlishman commented 7 years ago

See #16

infeenix commented 7 years ago

Replace the middleware.py source code with this, fixes the problem.

from django.utils.functional import SimpleLazyObject
from .utils import get_user_agent

class UserAgentMiddleware(object):

    def __init__(self, get_response=None):
        if get_response is not None:
            self.get_response = get_response

    def __call__(self, request):
        self.process_request(request)
        return self.get_response(request)

    def process_request(self, request):
        request.user_agent = SimpleLazyObject(lambda: get_user_agent(request))

The middleware is located in: site-packages/django_user_agents/

dpmontero commented 7 years ago

Hi, This is not updated on pip.

selwin commented 7 years ago

Version 0.3.2 is now on PyPI. Sorry for the delay.