mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 12:00:12 +03:00
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.
This commit is contained in:
parent
b2ec681d8d
commit
ad825341f8
|
@ -10,6 +10,7 @@ from __future__ import unicode_literals
|
||||||
|
|
||||||
import base64
|
import base64
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
from warnings import warn
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -623,7 +624,8 @@ class BrowsableAPIRenderer(BaseRenderer):
|
||||||
elif paginator is not None and data is not None:
|
elif paginator is not None and data is not None:
|
||||||
try:
|
try:
|
||||||
paginator.get_results(data)
|
paginator.get_results(data)
|
||||||
except (TypeError, KeyError):
|
except (TypeError, KeyError) as exc:
|
||||||
|
warn('get_filter_form() aborting because pagination failed: %s' % exc)
|
||||||
return
|
return
|
||||||
elif not isinstance(data, list):
|
elif not isinstance(data, list):
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue
Block a user