Code

Opened 3 years ago

Closed 3 years ago

#16796 closed New feature (wontfix)

isMobile() should be added to request objects

Reported by: anonymous Owned by: nobody
Component: HTTP handling Version: 1.3
Severity: Normal Keywords:
Cc: chris@… Triage Stage: Someday/Maybe
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently, in Django one needs to use a custom middleware to handle template switching logic for mobile view presentations. Here's my suggestion, since knowing whether a user is_mobile() is kind of a common scenario, or should be in modern web development, is it appropriate to add this be added to Django out of the box? There's a debate whether to do this in the user agent handling, however, it seems it might the most appropriate for our concerns. Here's two different custom middlewares that might be a good candidate examples for how to handle this for http://djangosnippets.org/snippets/2001/ or http://djangosnippets.org/snippets/2033/

Attachments (0)

Change History (3)

comment:1 Changed 3 years ago by cmheisel

  • Cc chris@… added
  • Component changed from Uncategorized to HTTP handling
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Someday/Maybe

Hi,

I'm not sure who submitted this ticket since it's marked as being reported by anonymous. You should visit the Trac register page to set up an account. That'll make it easier for you to follow the dialogue and to link up discussions on the django-developers list and in IRC with your tickets.

Your ticket asks a lot of questions, which means you might want to start by opening a thread in django-developers to get the thoughts of the community as to whether this is something that belongs in Django proper, or should be provided by third party libraries.

Thanks,

cmheisel

comment:2 Changed 3 years ago by lukeplant

I'm going to mark as WONTFIX, because:

  1. there is no obviously correct consensus on how to do the user-agent sniffing, or even consensus on whether this is the right approach at all, depending on what you are going to do with 'is_mobile'. AFAICS, 'is_mobile' takes a set of abilities that devices may have, each of which has to be represented by a large spectrum, and reduces them all to a single boolean, which is of dubious value for many uses.
  1. Unlike with other things that are in contrib, there is no great problem caused by different solutions to this problem, so there is no reason for this to go in core/contrib.
  1. As soon as we added this functionality, we would be taking on the burden of maintaining a database of user agent strings for 'mobiles' (and defining what that means).

This should remain as a snippet, or 3rd party solution.

comment:3 Changed 3 years ago by lukeplant

  • Resolution set to wontfix
  • Status changed from new to closed

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.