Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7k
Fix schema generation for PrimaryKeyRelatedField#5764
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
By default all subclasses of RelatedField are output as string fields inthe schema, which works well for StringRelatedField, SlugRelatedField orHyperlinkedRelatedField.Handle the common case of a PrimaryKeyRelatedField pointing to anAutoField.
jlaine commentedJan 24, 2018
On a related note, I noticed that including a foreign key field in "read_only_fields" nukes the "queryset" kwarg:
I understand why having this attribute is notrequired for a read-only field, but what is the harm in keeping it? Nuking this attribute removes the link to the foreign model and makes it much harder to generate a schema for the output of a serializer. |
carltongibson commentedFeb 1, 2018
@jlaine Just on your related note: my immediate thought is that if If that doesn't suit then put together a proper description and open a new ticket and we'll have a look. |
carltongibson left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yep. This looks good. Thanks!
jlaine commentedFeb 1, 2018
Thanks for merging this! Concerning the read_only_fields, explicitly declaring the field doesn't help : there is code to prevent you from providing a queryset on a field you declare as read_only. Not sure what the rationale is:
|
carltongibson commentedFeb 1, 2018
OK. Open a new ticket and we’ll think it through |
By default all subclasses of RelatedField are output as string fields inthe schema, which works well for StringRelatedField, SlugRelatedField orHyperlinkedRelatedField.Handle the common case of a PrimaryKeyRelatedField pointing to anAutoField.
Uh oh!
There was an error while loading.Please reload this page.
By default all subclasses of RelatedField are output as string fields in
the schema, which works well for StringRelatedField, SlugRelatedField or
HyperlinkedRelatedField.
Handle the common case of a PrimaryKeyRelatedField pointing to an
AutoField.