Wednesday, September 12, 2012

how can django detect user agent


how can django detect user agent - Google Search

http://stackoverflow.com/questions/2669294/how-to-detect-browser-type-in-django


You can extract that information from the request object like so:
request.META['HTTP_USER_AGENT']



http://stackoverflow.com/questions/164427/change-django-templates-based-on-user-agent

Rather than changing the template directories dynamically you could modify the request and add a value that lets your view know if the user is on an iphone or not. Then wrap render_to_response (or whatever you are using for creating HttpResponse objects) to grab the iphone version of the template instead of the standard html version if they are using an iphone.








No comments:

Post a Comment