-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Add 'default' value in OPTIONS #3773
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
Conversation
Hi, thanks for the PR. |
@Ernest0x So i case of a |
Yeah it make more sense to use the |
@cyberj Yes, If we also want to base the initial attribute of a ModelSerializer field to the default attribute of the corresponding model field, that is another decision to be taken. As an inspiration, as stated in the official documentation, Django's ModelForm (the equivalent of a ModelSerializer) uses in some cases the default value of a model field as an initial selection:
|
I'm not in favor of us making any changes to how we handle Custom requirements should implement this as a custom metadata class. For bonus points package it up and we can reference it from the docs. |
For some frameworks who rely on automatic form generation (Angular, Polymer..) we need to see the default option provided in
OPTIONS
metadata.I saw your concerns on Model's default attribute in #2683 so I have not included this on ModelSerializer for now.
But I think DRF shoul'd pass the model's
default
attribute in therest_framework.field.Field
when using a ModelSerializer to let thoses frameworks know what will be the value if not provided.