Django REST Framework: slow browsable UI because of large related table
Take a look at using an autocomplete widget, or drop down to using a dumb textfield widget.
Autocompletion docs here: http://www.django-rest-framework.org/topics/browsable-api/#autocomplete
You can force using TextInput with simple:
from django.forms import widgets
...
class YourSerializer(serializers.ModelSerializer):
param = serializers.PrimaryKeyRelatedField(
widget=widgets.TextInput
)
Or after proper autocomplete_light configuration:
import autocomplete_light
...
class YourSerializer(serializers.ModelSerializer):
paramOne = serializers.PrimaryKeyRelatedField(
widget=autocomplete_light.ChoiceWidget('RelatedModelAutocomplete')
)
paramMany = serializers.PrimaryKeyRelatedField(
widget=autocomplete_light.MultipleChoiceWidget('RelatedModelAutocomplete')
)
To filter out results which are returned by autocomplete_light this part of documentation.
Note that you can disable the HTML form and keep the raw data json entry with:
class BrowsableAPIRendererWithoutForms(BrowsableAPIRenderer):
"""Renders the browsable api, but excludes the forms."""
def get_rendered_html_form(self, data, view, method, request):
return None
and in settings.py:
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'rest_framework.renderers.JSONRenderer',
'application.api.renderers.BrowsableAPIRendererWithoutForms',
),
}
this will speed things up and you can still post from from the browsable ui.