From: Clint Ecker Date: Tue, 8 Jul 2008 15:02:15 +0000 (+0000) Subject: Fixing small errors regarding the optional model X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=b37b1ee1746f7cac1f67610135a7e92c6449fb53;p=django-google-tools.git Fixing small errors regarding the optional model --- diff --git a/models.py b/models.py index 3cdfb8f..1c245f3 100644 --- a/models.py +++ b/models.py @@ -1,4 +1,5 @@ from django.db import models +from django.conf import settings from django.contrib.sites.models import Site if getattr(settings, 'GOOGLE_ANALYTICS_MODEL', False): diff --git a/templatetags/analytics.py b/templatetags/analytics.py index 05a7df7..458d401 100644 --- a/templatetags/analytics.py +++ b/templatetags/analytics.py @@ -33,7 +33,10 @@ class AnalyticsNode(template.Node): def render(self, context): content = '' if self.site: - code = self.site.analytics_set.all()[0].analytics_code + try: + code = self.site.analytics_set.all()[0].analytics_code + except AttributeError: + return '' elif self.code: code = self.code else: