From ad825341f85b874ad350eb098fadfa9932d157d5 Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Fri, 12 Jan 2018 11:31:52 -0500 Subject: [PATCH] Warn if BrowsableAPIRenderer.get_filter_form fails I spent a bit of time trying to figure out why the filter form wasn't showing up for one custom class, which turned out to be because the paginator uses a hard-coded `results` key and the viewset method in question was using `records`. I fixed that in my code but a warning message for the exception would have made that much easier to find. --- rest_framework/renderers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index a2db9f228..7a815a59f 100644 --- a/rest_framework/renderers.py +++ b/rest_framework/renderers.py @@ -10,6 +10,7 @@ from __future__ import unicode_literals import base64 from collections import OrderedDict +from warnings import warn from django import forms from django.conf import settings @@ -623,7 +624,8 @@ class BrowsableAPIRenderer(BaseRenderer): elif paginator is not None and data is not None: try: paginator.get_results(data) - except (TypeError, KeyError): + except (TypeError, KeyError) as exc: + warn('get_filter_form() aborting because pagination failed: %s' % exc) return elif not isinstance(data, list): return