From e7ddaf5472ba3746da2a0e9dfed6326fc90ce08e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20T=C3=B6rnqvist?= Date: Sat, 18 May 2013 16:50:59 +0300 Subject: [PATCH] Turns out label and help_text are not always there --- rest_framework/renderers.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index a58025cd1..2b56d6e41 100644 --- a/rest_framework/renderers.py +++ b/rest_framework/renderers.py @@ -366,8 +366,11 @@ class BrowsableAPIRenderer(BaseRenderer): if getattr(v, 'default', None) is not None: kwargs['initial'] = v.default - kwargs['label'] = v.label - kwargs['help_text'] = v.help_text + if getattr(v, 'label', None) is not None: + kwargs['label'] = v.label + + if getattr(v, 'help_text', None) is not None: + kwargs['help_text'] = v.help_text fields[k] = v.form_field_class(**kwargs)