{{ site_name }} is returning host name instead of site name
See original GitHub issueIn customizing the Wagtail login page, I set up the following using {{ site_name }} as documented:
{% extends "wagtailadmin/login.html" %}
{% block branding_login %}Sign in to {{ site_name }}'s CMS{% endblock %}
I expected (and wanted) to see the site name on the login page, but instead it renders the host name. Is this how it is supposed to behave?
Technical details
- Python version: 3.6
- Django version: 2.1.4
- Wagtail version: 2.4
- Browser version: Chrome 71
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Web server changed name, url return wrong host name
The problem is the web server's name was server0, but now it was changed to server1. Still the old server name keeps showing...
Read more >URL problem: domain name changes to server name after login
The problem is after the user logs in successfully, the URL changes from showing the domain name (http://domain.com/liferay) to showing the server name...
Read more >UrlResolver.GetUrl always returns host name url
Hi,. For some reason, this line of code is always returning the host name url instead of the CMS page url. However, it...
Read more >Host name preservation - Azure Architecture Center
Learn how to preserve the original HTTP host name between a reverse proxy and its back-end web application in common Azure services.
Read more >How to access ServerUrl when sitecore website setup in ...
Normally you already specified the hostname in the site definition configuration file. You can get the hostname by calling. Sitecore.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@allcaps If there’s evidence that people are being persistently confused by these variables, then we should look at ways to prevent that - but I don’t think we can judge that based on one report.
I can’t think of any scenario where removing these variables would break anyone’s site, but I can’t rule out that possibility entirely - which means we’re stuck weighing up that probability against the probability that making the change will prevent someone in future from falling into this trap. Faced with those alternatives, I’d rather keep things as they are, so that we don’t risk breaking things for the user who is following the spec accurately.
@gasman Thank you for the thorough explanation and example.
I’m fine that Wagtail doesn’t want to make assumptions about multitenant systems.
There is still a small issue: Wagtail uses Django’s
auth_views.LoginView
. This Django view provides context containingsite
andsite_name
. But the values are looked-up in the Django way. They fall back to the domain name. The default login template doesn’t use these context variables.I’m not surprised that integrators assume that
site
andsite_name
context is the current Wagtail site and available for convenience. They only get the current domain name. That is not the expected behaviour.Should the
site
andsite_name
variables be removed from the login view context? Or are these redundant context variables something we can live with?I do understand the desire to display the current site name on a login page. The user is about to submit credentials and needs to know he is in the right place. Multitenant or single site setup, the requirement stays the same.
The fact that the view provides misleading context is a bug imho.