From 8215d1ee044582edd8aebdbd720af863489df936 Mon Sep 17 00:00:00 2001 From: Alan Trick Date: Fri, 5 Jan 2018 12:19:37 -0800 Subject: [PATCH 1/2] Use django's force_text This handles the case where the string is a gettext proxy object (https://github.com/limdauto/drf_openapi/issues/105) --- drf_openapi/entities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drf_openapi/entities.py b/drf_openapi/entities.py index 70bba2d..4430f61 100644 --- a/drf_openapi/entities.py +++ b/drf_openapi/entities.py @@ -5,7 +5,7 @@ import coreschema import uritemplate from coreapi import Link, Document, Field -from coreapi.compat import force_text +from django.utils.encoding import force_text from django.db import models from django.utils.functional import Promise from pkg_resources import parse_version From d6e07ea9ac139e46bf3cc2a3d75933e078a44748 Mon Sep 17 00:00:00 2001 From: Roman Tolkachyov Date: Sat, 3 Mar 2018 15:57:06 +0300 Subject: [PATCH 2/2] fix attribute check on model_field #132 --- drf_openapi/entities.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drf_openapi/entities.py b/drf_openapi/entities.py index 4430f61..02385d6 100644 --- a/drf_openapi/entities.py +++ b/drf_openapi/entities.py @@ -252,12 +252,12 @@ def get_path_fields(self, path, method, view): except: model_field = None - if model_field is not None and model_field.verbose_name: + if model_field is not None and hasattr(model_field, 'verbose_name'): title = force_text(model_field.verbose_name) - if model_field is not None and model_field.help_text: + if model_field is not None and hasattr(model_field, 'help_text'): description = force_text(model_field.help_text) - elif model_field is not None and model_field.primary_key: + elif model_field is not None and hasattr(model_field, 'primary_key'): description = get_pk_description(model, model_field) if hasattr(view, 'lookup_value_regex') and view.lookup_field == variable: