question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

{{ site_name }} is returning host name instead of site name

See original GitHub issue

In 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:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
gasmancommented, Jan 18, 2019

@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.

0reactions
allcapscommented, Jan 17, 2019

@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 containing site and site_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 and site_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 and site_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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found