From 01c8c0cad977fc0787dbfc78bd34f4fd37e613f4 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 10 Sep 2014 13:52:16 +0100 Subject: Added help_text argument to fields --- rest_framework/compat.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'rest_framework/compat.py') diff --git a/rest_framework/compat.py b/rest_framework/compat.py index fa0f0bfb..70b38df9 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -39,6 +39,17 @@ except ImportError: django_filters = None +if django.VERSION >= (1, 6): + def clean_manytomany_helptext(text): + return text +else: + # Up to version 1.5 many to many fields automatically suffix + # the `help_text` attribute with hardcoded text. + def clean_manytomany_helptext(text): + if text.endswith(' Hold down "Control", or "Command" on a Mac, to select more than one.'): + text = text[:-69] + return text + # Django-guardian is optional. Import only if guardian is in INSTALLED_APPS # Fixes (#1712). We keep the try/except for the test suite. guardian = None @@ -99,18 +110,8 @@ def get_concrete_model(model_cls): return model_cls -# View._allowed_methods only present from 1.5 onwards -if django.VERSION >= (1, 5): - from django.views.generic import View -else: - from django.views.generic import View as DjangoView - - class View(DjangoView): - def _allowed_methods(self): - return [m.upper() for m in self.http_method_names if hasattr(self, m)] - - # PATCH method is not implemented by Django +from django.views.generic import View if 'patch' not in View.http_method_names: View.http_method_names = View.http_method_names + ['patch'] -- cgit v1.2.3 From 80ba0473473501968154c5cc5dd5922e53d96a70 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 10 Sep 2014 16:57:22 +0100 Subject: Compat fixes --- rest_framework/compat.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'rest_framework/compat.py') diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 70b38df9..7c05bed9 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -110,8 +110,18 @@ def get_concrete_model(model_cls): return model_cls +# View._allowed_methods only present from 1.5 onwards +if django.VERSION >= (1, 5): + from django.views.generic import View +else: + from django.views.generic import View as DjangoView + + class View(DjangoView): + def _allowed_methods(self): + return [m.upper() for m in self.http_method_names if hasattr(self, m)] + + # PATCH method is not implemented by Django -from django.views.generic import View if 'patch' not in View.http_method_names: View.http_method_names = View.http_method_names + ['patch'] -- cgit v1.2.3