-
-
Notifications
You must be signed in to change notification settings - Fork 7k
[WIP/RFC] use field default value if not allow_null #5816
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
This is meant to be used with FK remote field lookups (`source = 'foo.bar'`), where `foo` is a model and `bar` is `None` there. serializers.CharField(source='foo.bar', default='default')
@carltongibson @blueyed Is this obsolete since 3.8? |
Does it still pass if rebased on master? I haven’t yet examined this one explicitly. |
Django RestFramwork Version: 3.8.0 |
Hi @arpit-draup. If you could provide a failing test case (e.g., as a PR), that would be helpful. |
Could you provide more details? I'm not following what you're asking. |
@rpkilby Can you please check this link : Stackoverflow. I have mentioned in detail. |
Except that since you override the generated field with an explicit field, whatever you did set on the model doesn't count. |
There has been some changes the way default values are handled for serialization. As far as I can tell it's been in the release notes. |
@xordoquy Okay but you understood the point, I am trying to make here? |
There were a whole bunch of issues around #5849 here. Unfortunately the old behaviour led to incorrect results, particularly with dotted-sources and default handling. We were forced to adjust, for v3.8. It gets pretty complex here. Without a failing test case in a separate PR it's not something we can think about changing easily. |
This is meant to be used with FK remote field lookups (
source = 'foo.bar'
), wherefoo
is a model andbar
isNone
there.No existing tests seem to be failing, and new one would be needed.
Not really sure if this is going to fly, so holding back on that for now.