From e2bd98a9ade63510724f143ade358c1668af4528 Mon Sep 17 00:00:00 2001 From: petercat12 Date: Fri, 28 Apr 2017 17:24:24 -0500 Subject: [PATCH] error handling... --- .../templatetags/pip_version_viewer_tags.py | 9 +++++---- example18/templates/admin/base_site.html | 11 ++++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/django_version_viewer/templatetags/pip_version_viewer_tags.py b/django_version_viewer/templatetags/pip_version_viewer_tags.py index c2a3f66..718f921 100644 --- a/django_version_viewer/templatetags/pip_version_viewer_tags.py +++ b/django_version_viewer/templatetags/pip_version_viewer_tags.py @@ -12,7 +12,8 @@ @register.inclusion_tag('version_viewer.html', takes_context=True) def show_pip_package_versions(context): - if accessor.allow_access(request=context['request']): - return {'allow': True} - else: - return {'allow': False} + request = context.get('request', None) + results = {'allow': False} + if request and accessor.allow_access(request=request): + results = {'allow': True} + return results diff --git a/example18/templates/admin/base_site.html b/example18/templates/admin/base_site.html index 5a012bd..d702e14 100644 --- a/example18/templates/admin/base_site.html +++ b/example18/templates/admin/base_site.html @@ -1,5 +1,12 @@ {% extends "admin/base.html" %} -{% load i18n pip_version_viewer_tags %} + +{% block title %}{{ title }} | {{ site_title|default:_('Django site admin') }}{% endblock %} + +{% block branding %} +

{{ site_header|default:_('Django administration') }}

+{% endblock %} + +{% load pip_version_viewer_tags %} {% block extrahead %} @@ -9,3 +16,5 @@ {% block pretitle %} {% show_pip_package_versions %} {% endblock %} + +{% block nav-global %}{% endblock %}