def device(request):
    ua = request.META.get('HTTP_USER_AGENT', '')
    parsed = user_agent_parser.Parse(ua)

    ua_parsed = (ugettext('unknown browser'), parsed['user_agent'])
    os_parsed = (ugettext('unknown system'), parsed['os'])

    infos = []
    for unknown, dct in (ua_parsed, os_parsed):
        d = dct.copy()

        family = d.pop('family')
        if family is None or family == 'Other':
            infos.append(unknown)
            continue

        version = '.'.join([d.get(k) for k in ('major', 'minor', 'patch') if d.get(k) is not None])
        if version:
            family = '%s %s' % (family, version)
        infos.append(family)

    return ' - '. join(infos)
Default device resolver using ua-parser.
dataset/ETHPy150Open ulule/django-safety/safety/resolvers.py/device