How do detect if template is being viewed on mobile device?

166 wyświetleń
Przejdź do pierwszej nieodczytanej wiadomości

Django2021

nieprzeczytany,
16 mar 2022, 16:28:3816.03.2022
do Django users

With Django how is it possible to detect
* if template is being viewed on mobile device?
and/or
* if template is being viewed in portrait or landscape mode?

Any suggestions appreciated.


Antonis Christofides

nieprzeczytany,
16 mar 2022, 16:34:0916.03.2022
do django...@googlegroups.com

Hello,

there are many ways to approach this problem, so it would be best to explain what you are trying to achieve.

Regards,

Antonis

Antonis Christofides
+30-6979924665 (mobile)
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7be1145e-662e-4d57-afa6-b9d178f7fb0fn%40googlegroups.com.

Kasper Laudrup

nieprzeczytany,
16 mar 2022, 16:34:1916.03.2022
do django...@googlegroups.com
https://www.w3.org/TR/css3-mediaqueries/

Kind regards,

Kasper Laudrup
OpenPGP_0xE5D9CAC64AAA55EB.asc
OpenPGP_signature

Django2021

nieprzeczytany,
16 mar 2022, 16:42:3916.03.2022
do Django users
> There are many ways to approach this problem, so it would be best to explain what you are trying to achieve.

Inside of a Django function or template we need to know if to display
a landscape or portrait of a form - based on knowing if the viewer is
using a mobile or not.

Django2021

nieprzeczytany,
16 mar 2022, 16:45:0116.03.2022
do Django users
If only https://www.w3.org/TR/css3-mediaqueries/  had some practical examples in Python or Django, it could be useful.

Antonis Christofides

nieprzeczytany,
17 mar 2022, 03:11:1017.03.2022
do django...@googlegroups.com

Inside of a Django function or template we need to know if to display
a landscape or portrait of a form - based on knowing if the viewer is
using a mobile or not.

Your requirement to know whether you are using "landscape or portrait" is unusual. Normally we are only interested in knowing the width of the screen. If the screen is wide enough, we show the wide version, without caring about what the height of the screen is (it could be a large screen in portrait, for example).

In any case, I think you can solve it with CSS (even if you really want to take the height of the screen into account). This problem has nothing to with Python and Django, it's merely a HTML+CSS issue. If you don't want to learn much CSS, using a CSS framework like Bootstrap can help.

Regards,

Antonis

Antonis Christofides



Wiadomość została usunięta
Wiadomość została usunięta

Kayode Oladipo

nieprzeczytany,
21 mar 2022, 07:01:3121.03.2022
do django...@googlegroups.com
Hello,
I had this exact problem, and I solved it using this package.

https://pypi.org/project/django-user-agents/

Cheers.

On Sun, Mar 20, 2022 at 7:01 PM Django2021 <dljons...@gmail.com> wrote:
Thanks for your answers.
Rephrasing question in another thread.
Odpowiedz wszystkim
Odpowiedz autorowi
Przekaż
Nowe wiadomości: 0