-
Notifications
You must be signed in to change notification settings - Fork 42
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
Dynamic serializer fields are not supported #108
Comments
Interesting... Didn't know it was a thing, is it something well supported by DRF? I'm wondering if there would be any unintended side effects. If you can make a PR with some good testing, I'll be happy to look into it, yes. |
There's another reference to drf-excel/drf_excel/renderers.py Line 244 in 0d47d7b
We should review and make sure there wouldn't be side-effects there. |
I thought |
@rptmat57 you're right. |
Hi, I'm trying to use a serializer that adds fields dynamically. However, XLSXRenderer is not able to pick up those fields.
Here's a simple example:
In the output XLSX, only
field_1
is included.I believe the use of
serializer.get_fields()
is the root cause:drf-excel/drf_excel/renderers.py
Line 277 in 0d47d7b
The default implementation of
get_fields()
in BaseSerializer returnsself._declared_fields
. This can be resolved by referencing toserializer.fields
instead.Let me know what you think. I can create an MR to fix it.
IMO, I think we should update this line to use
serializer.fields
as well.https://github.com/django-commons/drf-excel/blob/0d47d7bdfcfbe8d09e6186bfea46f8cdc76e2adc/drf_excel/renderers.py#L156C18-L156C29
The text was updated successfully, but these errors were encountered: