#17005: Adding django.contrib.site.middleware ?
-------------------------------+--------------------
     Reporter:  jordan@…       |      Owner:  nobody
         Type:  New feature    |     Status:  new
    Component:  contrib.sites  |    Version:
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 I end up doing something like the following all over my code:


 {{{
 from django.contrib.sites.models import Site

 def my_view(request, template_name="foo.html"):
     site = Site.objects.get_current()
     ...
     return render(request, template_name, locals())

 }}}

 Seems like it would save time (and possibly reduce database requests,
 depending on where else in the application the Site object is being used)
 if `django.contrib.sites.middleware.SiteMiddleware` was added, which
 either set `request.site` to `Site.objects.get_current()` or added `site`
 or `current_site` to the `RequestContext`

 I just did a search for "Site.objects.get_current" in one of my web apps
 and came up with 26 hits. There's really no reason to have to write out
 that code so many times. It should just be present as a variable
 somewhere.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17005>
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