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

0.13.2 dont resolve parameters with source= and @property #296

Closed
lsaavedr opened this issue Feb 13, 2021 · 3 comments
Closed

0.13.2 dont resolve parameters with source= and @property #296

lsaavedr opened this issue Feb 13, 2021 · 3 comments
Labels
bug Something isn't working fix confirmation pending issue has been fixed and confirmation from issue reporter is pending

Comments

@lsaavedr
Copy link
Contributor

Describe the bug

with @property

for example if MyModel has some property defined with:

    @property
    def foo(self):
        return None

and the serializer has:

    foo = PrimaryKeyRelatedField(...)

drf-spectacular fail with:

django.core.exceptions.FieldDoesNotExist: MyModel has no field named 'foo'

with source=

for example if my model has some parameters child like:

>>> from myapp.models import MyModel
>>> mc = MyModel.objects.first()
>>> mc.childName1.childName2 != None
True

then if the serializer has:

    foo = PrimaryKeyRelatedField(source="childName1.childName2", ...)

drf-spectacular fail with:

django.core.exceptions.FieldDoesNotExist: TrackerLog has no field named 'childName1.childName2'

To Reproduce
puts that kind of parameters (there exist anothers?)

Expected behavior
works like 0.13.1

@tfranzel
Copy link
Owner

hi @lsaavedr, so the only thing that changed was this bugfix here #275 from issue #274

i feared something like that would happen, as this code section is a whack-a-mole. i have trouble reproducing your exact issue though (only had time for testing@property verison). can you build a breaking example for both (ideally like in test_regressions.py)? that would help a lot

tfranzel pushed a commit that referenced this issue Feb 25, 2021
@tfranzel tfranzel added bug Something isn't working fix confirmation pending issue has been fixed and confirmation from issue reporter is pending labels Feb 25, 2021
@tfranzel
Copy link
Owner

@lsaavedr so the solution looks easier than it actually is. the source issue was indeed broken by another bugfix and should now be working for all the cases, hopefully.

the property examples provokes no error in your provided test. afais it works as expected without warning.

@lsaavedr
Copy link
Contributor Author

fixed!!! thanks!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fix confirmation pending issue has been fixed and confirmation from issue reporter is pending
Projects
None yet
Development

No branches or pull requests

2 participants