#8960: "View on site" does not work if contrib.sites is not installed
-----------------------------------+----------------------------------------
          Reporter:  bmihelac      |         Owner:  adrian
            Status:  assigned      |     Milestone:  1.2   
         Component:  Contrib apps  |       Version:  1.1   
        Resolution:                |      Keywords:        
             Stage:  Accepted      |     Has_patch:  1     
        Needs_docs:  0             |   Needs_tests:  0     
Needs_better_patch:  0             |  
-----------------------------------+----------------------------------------
Comment (by floledermann):

 I just looked into this - in my opinion a much simpler patch is
 sufficient:


 {{{
 --- django/contrib/contenttypes/views.py
 +++ django/contrib/contenttypes/views.py
 @@ -1,6 +1,6 @@
  from django import http
  from django.contrib.contenttypes.models import ContentType
 -from django.contrib.sites.models import Site
 +from django.contrib.sites.models import Site, RequestSite
  from django.core.exceptions import ObjectDoesNotExist

  def shortcut(request, content_type_id, object_id):
 @@ -54,7 +54,10 @@
      # Fall back to the current site (if possible).
      if object_domain is None:
          try:
 -            object_domain = Site.objects.get_current().domain
 +            if Site._meta.installed:
 +                object_domain = Site.objects.get_current().domain
 +            else:
 +                current_site = RequestSite(request).domain
          except Site.DoesNotExist:
              pass

 }}}

 If an explicit relationship to Site objects is established in a model
 (this is covered by the lines above my changes) it could be argued that
 the method should fail if the sites app is not installed.

 Unfortunately i do not have the infrastructure here to create a real patch
 against the trunk and run tests... I hope this helps, can somebody help to
 get this into 1.2?

-- 
Ticket URL: <http://code.djangoproject.com/ticket/8960#comment:11>
Django <http://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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to