From 4757a56002b2fe9e6f4120e3434f3a14fd04c665 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 16 Oct 2016 03:32:00 -0500 Subject: [PATCH] Fix bug in batch ID field renderer, when displayed for new batch Hopefully this is a good idea.. --- tailbone/forms/renderers/batch.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tailbone/forms/renderers/batch.py b/tailbone/forms/renderers/batch.py index 0c7034e0..76a6d5ca 100644 --- a/tailbone/forms/renderers/batch.py +++ b/tailbone/forms/renderers/batch.py @@ -40,9 +40,15 @@ class BatchIDFieldRenderer(fa.FieldRenderer): Renderer for batch ID fields. """ def render_readonly(self, **kwargs): - batch_id = self.raw_value - if batch_id: - return '{:08d}'.format(batch_id) + try: + batch_id = self.raw_value + except AttributeError: + # this can happen when creating a new batch, b/c the default value + # comes from a sequence + pass + else: + if batch_id: + return '{:08d}'.format(batch_id) return ''