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

Rebuild serializer on model refs update #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JargeZ
Copy link

@JargeZ JargeZ commented Aug 14, 2024

I just found it a problem for me
Please check ongoing fixes

@JargeZ JargeZ force-pushed the rebuild-serializer-on-model-refs-update branch from adb9d66 to 27dc774 Compare August 14, 2024 07:00
@georgebv
Copy link
Owner

Can you please provide a code snippet showing the problem? I'd like to understand the use case.

@JargeZ
Copy link
Author

JargeZ commented Aug 14, 2024

It is a case at least with recursive models

class Task(DRFBaseModel):
    id: UUID
    subtasks: list["Task"] | None = None
    
Task.update_forward_refs()  # v1 deprecated
Task.model_rebuild()

src/drf_pydantic/base_model.py Outdated Show resolved Hide resolved
@georgebv
Copy link
Owner

@JargeZ thank you. We don't support pydantic v1 so adding that for v2 should be enough. Can you please add some unit tests for recursive models and for rebuilding the model?

@JargeZ JargeZ force-pushed the rebuild-serializer-on-model-refs-update branch from 27dc774 to d06d5f8 Compare August 15, 2024 02:22
@JargeZ JargeZ force-pushed the rebuild-serializer-on-model-refs-update branch from d06d5f8 to 3c07b9b Compare August 15, 2024 02:37
@JargeZ JargeZ requested a review from georgebv August 15, 2024 04:30
@georgebv
Copy link
Owner

@JargeZ sorry for delayed response. I looked into this and I am confused as to how we should represent recursive models in DRF. There are ways to achieve this with recursive functions, but I don't think that's what we want.

Can you provide an example of what you expect the resulting recursive DRF serializer to look like?

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

Successfully merging this pull request may close these issues.

3 participants