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

RESTDanticGenericViewSet #1

Open
BezBartek opened this issue May 19, 2023 · 1 comment
Open

RESTDanticGenericViewSet #1

BezBartek opened this issue May 19, 2023 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@BezBartek
Copy link
Owner

BezBartek commented May 19, 2023

Create RESTDanticGenericViewSet (or propose a better name).

  • It has to inherit from drf GenericViewSet and be compatible with DRF
  • It uses instead of a DRF serializer a pydantic models
  • Focus on get_serializer_class method, it is the main method that relays on serializer_class interface.
    According to the discussion, our version of "get_Serializer_class" will:
  • recognize data input (dict, Django model instance, iterable of dicts, iterable of django models/queryset)
  • based on input use the proper model initialization method
  • among with data, provide context (as DRF does, it require to use our pydantic BaseModel version, that expects that)

Tech research needed to be done:

  • how pydantic from_orm method will behave with complex django instances, that have m2m, fields, check whether it would unpack correctly related querysets.
@BezBartek BezBartek added the enhancement New feature or request label May 19, 2023
@BezBartek BezBartek added this to the MVP milestone May 19, 2023
@BezBartek
Copy link
Owner Author

  1. It will inherit form views.APIView and reimplement GenericAPIView. Then we will compose RESTDanticGenericViewSet by combining our RestdanticGenericAPIView with ViewSetMixin. We do so to keep our names, and drop the "serializer" name.
  2. RESTDanticGenericViewSet will support action - pydantic model mapping. Pydantic is less elastic than DRF, and it would require from user to create more models than DRF does. We will cover that need by implementing mapping mechanism
  3. Main method would be get_pydantic_scheme, that will do pydantic validation and schema wrapping (we can't make that steps separate as DRF does, because pydantic limitations).
  4. Everywhere where Pydantic Models would have names collision with Django models, we will call them Schemas.

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

No branches or pull requests

1 participant