P
P
pvgdrk2016-03-11 14:48:33
Django
pvgdrk, 2016-03-11 14:48:33

Why doesn't the {{ site.domain}} tag work in a Django template?

I'm trying to get the domain name through the template tag:
<form action="http://{{ site.domain }}" + "...">
But an empty url is rendered:
<form action="http://">
What and where else should I do to make it work?
UPD
'django.contrib.sites' is available

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2016-03-11
@pvgdrk

{{}}is not a tag, it's a variable substitution expression. Apparently, there is no variable in the context site. You can pass it in from a view, write your own context processor, or use django.contrib.sites.middleware.CurrentSiteMiddleware .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question