Be more defensive in our 404 handler
@@ -176,7 +176,9 @@ def server_error_404_subdomain(request, template_name='404.html'):
version = None
if version_slug:
- version = project.versions.get(slug=version_slug)
+ version_qs = project.versions.filter(slug=version_slug)
+ if version_qs.exists():
+ version = version_qs.first()
private = any([
version and version.privacy_level == PRIVATE,
@@ -192,6 +194,7 @@ def server_error_404_subdomain(request, template_name='404.html'):
project, full_path = project_and_path_from_request(request, request.get_full_path())
+ if project:
language = None
version_slug = None
schema, netloc, path, params, query, fragments = urlparse(full_path)
