Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

redirect the domainname.com website to m.domainname.com in django for mobile devices

I want to redirect the user to m.domainname.com on his mobile browser. I want to use the existing website but redirect to the m.domainname.com. For that how can i detect the user is on mobile or desktop. And how can i redirect the mobile version of same site.

using media screen i can create the seprate displays for mobile divices

using bootstrap i can create the responsive website. but when its on mobile browser i want to redirect the mobile version like m.domainname.com

How can i do this? And my website is in django.

like image 209
Wagh Avatar asked Jan 24 '26 07:01

Wagh


1 Answers

You can use something like this: https://github.com/gregmuellegger/django-mobile The idea is to detect mobile device in middleware (https://docs.djangoproject.com/en/dev/topics/http/middleware/).

So, if middleware detects that request going from mobile device, and user requested the normal version of the site, you can redirect him to mobile version of the site.

like image 91
coldmind Avatar answered Jan 25 '26 21:01

coldmind



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!