Skip to content
Open
16 changes: 13 additions & 3 deletions djangoproject/templates/404.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
{% extends 'base_error.html' %}
{% load i18n %}
{% load i18n docs %}

{% block title %}{% translate "Page not found" %}{% endblock %}

{% block header %}<h1>404</h1>{% endblock %}
{% block header %}
<div class="copy-banner">
<div class="container--flex container--flex--wrap--mobile">
<h1>404</h1>
{% if request.host.regex == 'docs' %}
{% search_form %}
{% endif %}
</div>
</div>
{% endblock %}

{% block content %}
<h2>{% translate "Page not found" %}</h2>
Expand All @@ -12,7 +21,8 @@ <h2>{% translate "Page not found" %}</h2>
{% blocktranslate trimmed %}
Looks like you followed a bad link. If you think it's our fault, please
<a href="https://code.djangoproject.com/">let us know</a>.
{% endblocktranslate %}</p>
{% endblocktranslate %}
</p>

{% url 'homepage' as homepage_url %}
<p>
Expand Down
17 changes: 13 additions & 4 deletions docs/templatetags/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,23 @@
@register.inclusion_tag("docs/search_form.html", takes_context=True)
def search_form(context):
request = context["request"]
version = ""
lang = ""
exception = context.get("exception", "")
if exception:
lang = context["LANGUAGE_CODE"]
version = context["DOCS_VERSION"]
else:
version = context["version"]
lang = context["lang"]
release = DocumentRelease.objects.get_by_version_and_lang(
context["version"],
context["lang"],
version,
lang,
)
return {
"form": DocSearchForm(request.GET, release=release),
"version": context["version"],
"lang": context["lang"],
"version": version,
"lang": lang,
}


Expand Down