Open peca11 opened 4 years ago
I am having trouble with this same problem. Currently, I am using this module to separate the loading of css by user-agent, but if ipad of chrome, both is_tablet and is_mobile returned true, so both css are loaded and corrupted. Any help is welcome. Thank you.
Currently, both iPad Air and iPad mini return "true" for both is_mobile and is_tablet. Due to this situation, although I made CSS file separated mobile and tablet, both css loaded.
Regarding this issue, I was able to solve it with the following code.
{% if request.user_agent.is_mobile and 'iPad' not in request.user_agent.device %}
<link rel="stylesheet" href="{% static 'css/custom-style-sp.css' %}">
{% endif %}
{% if request.user_agent.is_tablet %}
<link rel="stylesheet" href="{% static 'css/custom-style-tablet.css' %}">
{% endif %}
In the above code, ipad air and ipad mini will only be true for the tablet and only the code for the tablet will be loaded. (I'm only validating with chrome's dev tool.)
On Chrome for Ipad the method is_mobile and is_tablet returns True for both cases.
Is this normal? Shouldn't it return False for mobile?
Are there any other known situations where mobile and tablet both return True?
Thanks!