• About Us
  • Blog
  • Basket
  • Account
  • Sign In

Python V3.1 Documentation

You are viewing an old version of the documentation. For the latest, please go here: Python V3.2


51Degrees Mobile Detector for python provides a middleware and a context processor designed to simplify the integration of the detection solution in Django platforms. This article assumes that Django is already being used.

Step 1: Install your preferred 51Degrees python mobile detection package using pip (the core package will be installed automatically as a dependency). For pattern matching:

pip install 51degrees-mobile-detector-v3-wrapper

For trie matching:

pip install 51degrees-mobile-detector-v3-trie-wrapper

Step 2: Add the 51Degrees Mobile Detector middleware to your Django settings. Inserting it just after "SessionMiddleware" is a safe place for it:


Step 3:Configure the solution. When integrating 51Degrees Mobile Detector for Python with a Django website, there is an extra and more convenient option to set your preferences directly in your Django settings.

    'DETECTION_METHOD': 'lite-pattern-wrapper',
    'PROPERTIES': ('Id', 'IsMobile', 'WebWorkers', 'Html5'),

Step 4:The middleware provides some extra settings only available for Django users:


If enabled, information about the detected device will be cached in the user's session.


If session cache is set and the enabled, it allows configuring the caching key in the user's session. To see a demo of Django working with 51Degrees Python solution visit the blog.