-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using a renderer in DRF settings for Excel output option #28
Comments
This use case wasn't fully supported before, but it was an easy fix. I added some more descriptive error messages and also updated the documentation here. The error is that if you have a One way to fix the import order is to add |
Hey there. Thanks for the response. I've followed your instructions listed above, and am still running into issues. In my settings file, I've included rest_pandas in my included apps. Then in my models, I defined a objects = DataFrameManager(), right before the class Meta definition. My serializer is a ModelSerializer. And my View is passing PandasMixin, ListAPIView. Listed below is my code. ` (serializer.py)
(views.py)
` Much to my chagrin, I'm still getting a "Response data is a <class 'rest_framework.utils.serializer_helpers.ReturnList'>, not a DataFrame!" error. In short, what am I doing wrong? I thought the (objects = DataFrameManager()) defined in the model, would return a DataFrame. Thanks in advance for the assist. Take care and have a good day. Sincerely, JG |
Thanks very much for our efforts, @sheppard - but I'm having a similar issue to JG, and I think I'm close. I've installed the latest
I've modified my
I can browse the HTML version of the DRF API, and
I've started digging through the code, but any help you could provide would be fantastic. Thanks again for your efforts on DRP - much appreciated! |
Remove DEFAULT_PAGINATION_CLASS in your settings. |
In my case, the above error was directly related to pagination and I didn't want to disable DEFAULT_PAGINATION_CLASS. As a quick workaround for the problem, I override ListMixin and check to see if the URL parameter "format" exists. I don't use a format extension (/path.csv) so I didn't bother to add it.
I then use the above mixin on my viewsets and all is well.
|
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:
I haven't included it in
INSTALLED_APPS
as I've read about the problems that causes. However, when trying this method, Django'srunserver
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 showsapplication/json
andtext/html
under therenders
section: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! :)
The text was updated successfully, but these errors were encountered: