From 5ad5cb569d1f1e5ff0ebbd41395cdc2644b41172 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 10 Feb 2015 11:23:35 -0600 Subject: [PATCH] Only attempt to count versions for versioned models. --- tailbone/views/crud.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tailbone/views/crud.py b/tailbone/views/crud.py index ab74aa60..924c91de 100644 --- a/tailbone/views/crud.py +++ b/tailbone/views/crud.py @@ -34,6 +34,7 @@ except ImportError: import sqlalchemy as sa from sqlalchemy_continuum import transaction_class, version_class +from sqlalchemy_continuum.utils import is_versioned from rattail.db import model from rattail.db.model.continuum import count_versions, model_transaction_query @@ -169,9 +170,9 @@ class CrudView(View): pass def template_kwargs(self, form): - if form.creating: - return {} - return {'version_count': self.count_versions()} + if not form.creating and is_versioned(self.mapped_class): + return {'version_count': self.count_versions()} + return {} def count_versions(self): query = self.transaction_query()