Skip to content
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

Create unique type names in FlexFieldsMixin #9

Closed
joeribekker opened this issue Feb 15, 2018 · 1 comment
Closed

Create unique type names in FlexFieldsMixin #9

joeribekker opened this issue Feb 15, 2018 · 1 comment

Comments

@joeribekker
Copy link

All fields that are expandable will get the same serializer names. It's not directly an issue with this library but this causes issues with (for example) schema generation where names -can- be based on serializer class names.

Perhaps include the original serializer name in the generated type name.

In views.py:50 change this:

-		return type('DynamicFieldsModelSerializer', (self.serializer_class,), {
+		return type('{}FlexFieldsSerializer'.format(self.serializer_class.__name__), (self.serializer_class,), {
			'expand': expand, 
			'include_fields': fields,
		})
@rsinger86
Copy link
Owner

rsinger86 commented Feb 18, 2018

This implementation was actually altered in the latest version. The request query params (expand and fields) now get injected via the serializer context, rather than dynamic modification of the serializer class to incorporate them. This seemed less magical/more aligned with the DRF API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants