A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/wq/django-rest-pandas/issues/28 below:

Using a renderer in DRF settings for Excel output option · Issue #28 · wq/django-rest-pandas · GitHub

I'm trying to create an option on all of my endpoints to output XLS files when the appropriate header is set. I may not be understanding correctly, but here's what I've tried to do:

REST_FRAMEWORK = {
    ...
    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
        'rest_framework.renderers.BrowsableAPIRenderer',
        'rest_pandas.renderers.PandasExcelRenderer',
    ),
}

I haven't included it in INSTALLED_APPS as I've read about the problems that causes. However, when trying this method, Django's runserver is giving me this error:

ImportError: Could not import 'rest_pandas.renderers.PandasExcelRenderer' for API setting 'DEFAULT_RENDERER_CLASSES'. ImportError: cannot import name 'APIView'.

When I try this, runserver comes up but the OPTIONS only shows application/json and text/html under the renders section:

from rest_pandas.renderers import PandasExcelRenderer

REST_FRAMEWORK = {
...
    'DEFAULT_RENDERER_CLASSES': (
        'rest_framework.renderers.JSONRenderer',
        'rest_framework.renderers.BrowsableAPIRenderer',
        PandasExcelRenderer,
    ),
}

I'm sure I'm missing something simple, and I'll be happy to issue a how-to PR on the README if someone can help me get this working! :)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4