From a4aed148ceb7c3b051458c723f15a4ac520beff5 Mon Sep 17 00:00:00 2001 From: Alexandre Varas Date: Wed, 22 Jun 2016 10:14:47 +0200 Subject: [PATCH 1/2] Added `help_text` to fields --- demo/project/accounts/models.py | 2 +- rest_framework_docs/api_endpoint.py | 3 ++- .../templates/rest_framework_docs/components/fields_list.html | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/demo/project/accounts/models.py b/demo/project/accounts/models.py index 069a0c6..91339ac 100644 --- a/demo/project/accounts/models.py +++ b/demo/project/accounts/models.py @@ -7,7 +7,7 @@ class User(AbstractBaseUser): modified = models.DateTimeField(auto_now=True) email = models.EmailField(unique=True, verbose_name='email address', max_length=255) - full_name = models.CharField(max_length=255) + full_name = models.CharField(max_length=255, help_text='Yes, the full name!') is_active = models.BooleanField(default=False) is_admin = models.BooleanField(default=False) diff --git a/rest_framework_docs/api_endpoint.py b/rest_framework_docs/api_endpoint.py index 89a33f8..cec4e6b 100644 --- a/rest_framework_docs/api_endpoint.py +++ b/rest_framework_docs/api_endpoint.py @@ -104,7 +104,8 @@ def __get_serializer_fields__(self, serializer): "type": str(field.__class__.__name__), "sub_fields": sub_fields, "required": field.required, - "to_many_relation": to_many_relation + "to_many_relation": to_many_relation, + "help_text": field.help_text or '', }) # FIXME: # Show more attibutes of `field`? diff --git a/rest_framework_docs/templates/rest_framework_docs/components/fields_list.html b/rest_framework_docs/templates/rest_framework_docs/components/fields_list.html index a351946..25c3e11 100644 --- a/rest_framework_docs/templates/rest_framework_docs/components/fields_list.html +++ b/rest_framework_docs/templates/rest_framework_docs/components/fields_list.html @@ -6,6 +6,8 @@ R {% endif %} + {% if field.help_text %}

Help: {{ field.help_text }}

{% endif %} + {% if field.to_many_relation %} Array of objects {% endif %} From f4b4e74b50f5b0083ea8fb80674793e1237e6f26 Mon Sep 17 00:00:00 2001 From: Anc813 Date: Fri, 26 Aug 2016 15:53:01 +0300 Subject: [PATCH 2/2] Update api_endpoint.py --- rest_framework_docs/api_endpoint.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework_docs/api_endpoint.py b/rest_framework_docs/api_endpoint.py index cec4e6b..b2112f0 100644 --- a/rest_framework_docs/api_endpoint.py +++ b/rest_framework_docs/api_endpoint.py @@ -105,7 +105,7 @@ def __get_serializer_fields__(self, serializer): "sub_fields": sub_fields, "required": field.required, "to_many_relation": to_many_relation, - "help_text": field.help_text or '', + "help_text": str(field.help_text or ''), }) # FIXME: # Show more attibutes of `field`?