I need to detect 3 types of device: tablet
, mobile
or desktop
.
I found a script for detecting mobile on github, but how I can det
Use django-user_agents
from django_user_agents.utils import get_user_agent
def my_view(request):
user_agent = get_user_agent(request)
if user_agent.is_mobile:
# identified as a mobile phone (iPhone, Android phones, Blackberry, Windows Phone devices etc)
if user_agent.is_tablet:
# identified as a tablet device (iPad, Kindle Fire, Nexus 7 etc)
if user_agent.is_pc:
# identified to be running a traditional "desktop" OS (Windows, OS X, Linux)
It uses user_agents under the hood.