django-user_agents icon indicating copy to clipboard operation
django-user_agents copied to clipboard

Chrome on Ipad returns True for Mobile and Tablet

Open peca11 opened this issue 5 years ago • 2 comments

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!

peca11 avatar Jun 22 '20 20:06 peca11

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.

DevWoody856 avatar Jan 08 '22 15:01 DevWoody856

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.)

DevWoody856 avatar Jan 25 '22 14:01 DevWoody856