Задать вопрос

Тел: +7 965 3737 888

466

Просмотров

1

Ответов

Add site info to request context

<p>Sometimes you want to generate a <strong>really</strong> absolute URL, but the built-in url tag only generates a URL relative to the current domain. This context processor adds the extra information needed to the request context, so you can generate an absolute URL in a template like so:
</p>
<p>{{ protocol }}://{{ domain }}{% url someview %}
</p>
<p>This is similar to how the password reset email from contrib.auth generates the full URL in the email.
</p>
<p>Save this somewhere as context_processors.py (or add to existing file if you have one), and add context_processors.site to your TEMPLATE_CONTEXT_PROCESSORS setting.
</p>

Вопрос полезен? Да0/Нет0
file_3649.py(339.0б)
None

Ответы (1):

Ответarchatas:17.11.2008
Ответ полезен? Да0/Нет0

The absolute url might also include a specific port. So that should be also included into the snippet.