-
Notifications
You must be signed in to change notification settings - Fork 274
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
SlugRelatedField with DataclassSerializer #897
Comments
of course there are multiple ways of using this field. 😞 I had a gut feeling this may produce issues. will look into it. |
@HansAarneLiblik please review and test #899. hopefully this will do the trick. |
@tfranzel Seems to work perfectly ! |
utilize queryset for SlugRelatedField #897
Not related to this, but my test between 0.24 and 0.25 showed that schema generation speed has drastically decreased. If needed I can generate some numbers |
Well, i'm pretty sure this is due to your requested feature #866 I found that these two lines for getting the source are quite expensive: https://github.com/tfranzel/drf-spectacular/pull/889/files#diff-d93b8eca9df4d268a9d1ae33010b6119414e6a61a5d736e39a1650f8975a72edR114-R115 It doubled the test suite execution time by itself. However, I added a cache which brought it down to the previous performance. I thought 1000 cache size is a fair guestimate for number of serializer/views in an API. Please provide some number so we can further improve this |
330kb yaml 13.6k lines 0.24.2: 0.25.0: NOTE: These values about double when running Django in About the results - I love that it shows the file path, but it only does it for a few cases. Most of our errors don't have it. (Of the ~100 errors, these following 8 are the only cases they exist) |
😅 thats a hefty one
sounds good and it looks like the cache size is sufficient.
That is to be expected I suppose unless there is a more efficient stdlib method for getting the file and line number, which I couldn't find.
Not sure why that is exactly. We don't do anything special for debug=True.
That is also mostly expected. There is no path for warn/errors that are happening outside of the actual view parsing, e.g. preprocessing, postprocessing, setup. Those happen outside of any I'm considering turning off the filepath for |
@HansAarneLiblik however if those msg are |
I think I found the issue regarding missing paths. You are using a lot of |
Indeed we're using mostly |
@HansAarneLiblik what do you think about only showing the path (and line if available) in CLI only ( |
Sure, Seems like a reasonable way to go ! |
CLI will run with line numbers, Schema view will not.
Describe the bug
With version 0.25.0, our schema generation started to fail, because we use
SlugRelatedField
withDataclassSerializer
notModelSerializer
, and therefore do not havefield.parent.Meta.model
field, but have providedqueryset
attr toSlugRelatedField
constructor, which should be used to detect the type insteadSource of bug: 0307ff9#diff-4d081c8c817b2246109e52886d6b1f078858a2d5c99ea6e694796e39a7d96d77R662
#893
To Reproduce
Expected behavior
model
to be determined from providedqueryset
model = field.queryset.model if hasattr(field, "queryset") else getattr(field.parent.Meta, "model", None)
or perhaps try to deduct from dataclass field type ?
The text was updated successfully, but these errors were encountered: