--
Ticket URL: <https://code.djangoproject.com/ticket/17005>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_docs: => 0
* needs_better_patch: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted
Comment:
I think the cleanest solution is to set `request.site =
Site.objects.get_current()`. I wouldn't use `get_current_site()` because
this middleware doesn't make sense when the `sites` app isn't enabled. The
current site is cached, so the performance impact is negligible.
This middleware will be trivial, but it could be useful, and I don't see
any reason not to include it in Django. It's similar to the `static` and
`media` context processors.
--
Ticket URL: <https://code.djangoproject.com/ticket/17005#comment:1>
Comment (by jordan@…):
I'd be happy to be involved with the coding of it.
> It's similar to the static and media context processors."
So do you think it should be made available via a context processor, or as
middleware?
--
Ticket URL: <https://code.djangoproject.com/ticket/17005#comment:2>
Comment (by jordan@…):
I'd be happy to be involved with the coding of it.
> It's similar to the static and media context processors."
So do you think it should be made available via a context processor, or as
middleware?
--
Ticket URL: <https://code.djangoproject.com/ticket/17005#comment:2>
Comment (by aaugustin):
A middleware is more appropriate — I expect the current site object to be
used in the view rather than in the template.
The comparison with the static and media context processors was just about
the triviality of the code.
--
Ticket URL: <https://code.djangoproject.com/ticket/17005#comment:3>
* owner: nobody => anonymous
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/17005#comment:4>
* owner: anonymous => krzysiumed
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/17005#comment:5>
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/17005#comment:6>
Comment (by krzysiumed):
I'd written a patch. It contains docs and tests (I believe they are not
necessary, because the middleware is very simple). Sorry for my poor
English in docs.
--
Ticket URL: <https://code.djangoproject.com/ticket/17005#comment:7>
* has_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/17005#comment:8>
* cc: krzysiumed@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/17005#comment:9>
Comment (by aaugustin):
#13559 is about adding a context processor for the same purpose in
templates.
--
Ticket URL: <https://code.djangoproject.com/ticket/17005#comment:10>
* owner: krzysiumed => chrismedrela
Comment:
I've updated the patch: https://github.com/django/django/pull/1939. BTW,
krzysiumed is my old nick.
--
Ticket URL: <https://code.djangoproject.com/ticket/17005#comment:11>
* stage: Accepted => Ready for checkin
Comment:
The code looks good to me. Can someone review the docs?
--
Ticket URL: <https://code.djangoproject.com/ticket/17005#comment:12>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"b22d6c47a7e4c7ab26a8b7b033d11fa6743aae86"]:
{{{
#!CommitTicketReference repository=""
revision="b22d6c47a7e4c7ab26a8b7b033d11fa6743aae86"
Fixed #17005 -- Added CurrentSiteMiddleware to set the current site on
each request.
Thanks jordan at aace.org for the suggestion.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/17005#comment:13>
--
Ticket URL: <https://code.djangoproject.com/ticket/17005#comment:14>