diff --git a/djangoproject/templates/404.html b/djangoproject/templates/404.html index 885c594a3..1e421a896 100644 --- a/djangoproject/templates/404.html +++ b/djangoproject/templates/404.html @@ -1,9 +1,18 @@ {% extends 'base_error.html' %} -{% load i18n %} +{% load i18n docs %} {% block title %}{% translate "Page not found" %}{% endblock %} -{% block header %}

404

{% endblock %} +{% block header %} +
+
+

404

+ {% if request.host.regex == 'docs' %} + {% search_form %} + {% endif %} +
+
+{% endblock %} {% block content %}

{% translate "Page not found" %}

@@ -12,7 +21,8 @@

{% translate "Page not found" %}

{% blocktranslate trimmed %} Looks like you followed a bad link. If you think it's our fault, please let us know. - {% endblocktranslate %}

+ {% endblocktranslate %} +

{% url 'homepage' as homepage_url %}

diff --git a/docs/templatetags/docs.py b/docs/templatetags/docs.py index 194a77e7f..1d54efb46 100644 --- a/docs/templatetags/docs.py +++ b/docs/templatetags/docs.py @@ -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, }