-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
M2M model field without blank=True
should map to a serializer relationship with allow_empty=False
.
#2804
Comments
See test in #2674. |
+1 |
For both this and #2674 I'm unsure exactly what behavior you're expecting. Are you expecting to be able to provide As currently described the existing behavior seems correct to me - require the input, but allow it to be an empty list. |
See my answer in #2674. If (The other point (not this issue) is that the required flag should be controlled by the model field option |
I agree with #2674 (comment) |
+1 |
required=True
should map to a serializer relationship with allow_empty=False
.
required=True
should map to a serializer relationship with allow_empty=False
.null=True
should map to a serializer relationship with allow_empty=False
.
null=True
should map to a serializer relationship with allow_empty=False
.blank=True
should map to a serializer relationship with allow_empty=False
.
Retitled more appropriately. I'm not 100% convinced that we want If we do change the behavior we should do so in a major version bump and call it out prominently. Requires #2250 as a prerequisite. |
+1 |
Accepting this, though given the potential for backwards incompatibility it's probably a good idea if we push it in 3.2.0, to allow us to call it out. |
Also note that |
Still open: Setting the M2M model field with blank=True does not set required=False as expected. (M2M fields with blank=False work as expected). Unfortunately I can not reopen this issue but open a new one if you like. |
Not sure I'd accept that as valid or not, but welcome to open it. Defiantly should be considered seperators in any case. |
The Django 1.8 system check framework displays the warning fields.W340 when the
null
parameter is defined on aManyToManyField
, since it has no effect.This
null
field affects on whether a related field in a model serializer is considered required or not. We can see it here.From my point of view, this behavior is correct for a
ForeignKey
but not for aManyToManyField
, that should be considered not required by default.Adding the var
to_many
to the condition on the aforementioned code might do the trick.The text was updated successfully, but these errors were encountered: