Commits

Jesús Espino committed c280777 Merge

Merged in nemesisfixx/django-visits-1/nemesisfixx/visits_tagspy-edited-online-with-bitbuck-1400767321310 (pull request #5)

visits_tags.py edited online with Bitbucket

Comments (0)

Files changed (1)

visits/templatetags/visits_tags.py

     def render(self, context):
         obj = self.obj.resolve(context)
         
-        if isinstance(obj, dict):
+        if isinstance(obj, basestring):
+            context[self.context_var] = Visit.objects.filter(
+                uri__regex=obj,
+            ).aggregate(visits_sum=Sum("visits"))["visits_sum"]
+        elif isinstance(obj, dict):
             context[self.context_var] = Visit.objects.filter(
                 uri=obj["request_path"],
             ).aggregate(visits_sum=Sum("visits"))["visits_sum"]