3

I have tried using request.META['HTTP_USER_AGENT'] for detecting the browser . But this returns the type of browsers list when i tested on

chrome: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36

instead of just returning chrome and similarly on :

edge: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 Edge/16.16299

mozilla: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0

** I am not able to get the pattern in which it is returning values. Can anyone tell the way by which i could get the browser name

2
  • 6
    This doesn't really have to do with Django. What you want is a User Agent string database that will map a User Agent string to a reasonable browser family. However, as I'm sure many other web developers will tell you, trying to guess the browser from the UA string is mostly an exercise in vain. Commented Apr 17, 2018 at 15:44
  • 1
    Maybe you are interested in reading about why the user agent string is such a mess: reddit post why_every_user_agent_string_start_with_mozilla and direct link to the article Commented Apr 17, 2018 at 15:50

1 Answer 1

1

You can use request object for the same:

request.META['HTTP_USER_AGENT']

also there is a package for that : django-user-agents

Sign up to request clarification or add additional context in comments.

1 Comment

request.META['HTTP_USER_AGENT'] returns list of browsers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.