Skip to content

Instantly share code, notes, and snippets.

@Walkeryr
Created August 24, 2015 16:04
Show Gist options
  • Save Walkeryr/f01dc77eab271018fbef to your computer and use it in GitHub Desktop.
Save Walkeryr/f01dc77eab271018fbef to your computer and use it in GitHub Desktop.
def detect_mobile(f):
def wrapped(*args, **kwargs):
request = args[0]
if request.mobile and not request.tablet:
path_lang = request.path.find('/en/')
if path_lang != -1 and request.path.find('/mobile/') == -1:
return HttpResponseRedirect('/en/mobile' + request.path[3:])
return HttpResponseRedirect('/mobile' + request.path)
return f(*args, **kwargs)
return wrapped
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment