selwin / django-user_agents

A django package that allows easy identification of visitor's browser, OS and device information, including whether the visitor uses a mobile phone, tablet or a touch capable device.
MIT License
640 stars 104 forks source link

Chrome on Ipad returns True for Mobile and Tablet #37

Open peca11 opened 4 years ago

peca11 commented 4 years ago

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!

DevWoody856 commented 2 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.

DevWoody856 commented 2 years ago

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