#18620: Prefer current Site when checking M2M in "shortcut"/"view_on_site" 
redirect
--------------------------------------+--------------------
     Reporter:  mtigas                |      Owner:  nobody
         Type:  Cleanup/optimization  |     Status:  new
    Component:  contrib.contenttypes  |    Version:  1.4
     Severity:  Normal                |   Keywords:
 Triage Stage:  Unreviewed            |  Has patch:  0
Easy pickings:  0                     |      UI/UX:  0
--------------------------------------+--------------------
 Given an object with a many-to-many relationship to
 `django.contrib.sites.models.Site`, the
 `django.contrib.contenttypes.views.shortcut` view simply picks the first
 domain returned, basically `obj.<field>[0].domain`.
 
(https://github.com/django/django/blob/4a103086/django/contrib/contenttypes/views.py#L45
 -- it even notes that the ordering is arbitrary.)

 This can be confusing when operating several (shared database) Django
 sites where sometimes content is cross-posted between said sites.

 Example that led to my noticing this issue: A story being edited on
 www.spokesman.com but posted to sites [www.spokesman.com,
 www.downtoearthnw.com] redirects you to story's representation on the
 latter website when clicking "view on site" in the admin (or using
 anything else that uses that underlying `shortcut` view). (Ostensibly
 because "www.downtoearthnw.com" sorts before "www.spokesman.com" and is
 therefore picked by the simple code I linked above.) Although this is a
 ''theoretically acceptable'' thing to happen, it's confusing to (even
 technical) users because they're ''on'' one of the acceptable sites for
 the content object and do not expect to be redirected to another site.

 I propose that the view should prefer the current site in the event that
 both of the following are true:

 a) the content object "Site" field is an M2M
 b) the current Site object is one of the values set in that M2M

 This shouldn't change behavior in any other circumstance (current site not
 in that M2M, site field is not M2M, etc), but it should alleviate some
 confusion to this specific usecase.

 Have code and will post in a GitHub fork shortly.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18620>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to