Adding a validation check enforcing that blank=False when null=False to
catch such errors/warnings and displaying appropriate message so that the
user is fully aware of the situation.
--
Ticket URL: <https://code.djangoproject.com/ticket/22656>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => assigned
* needs_better_patch: => 0
* needs_tests: => 0
* owner: nobody => anubhav9042
* needs_docs: => 0
* has_patch: 0 => 1
Comment:
https://github.com/django/django/pull/2686
--
Ticket URL: <https://code.djangoproject.com/ticket/22656#comment:1>
Comment (by aaugustin):
I assume you meant "blank=False when null=False" instead of "null=True
with blank=True"?
--
Ticket URL: <https://code.djangoproject.com/ticket/22656#comment:2>
Comment (by timo):
I'm not sure this is something we want to add as it will break backwards
compatibility. For example, "Leaving a field blank and filling it in in
the model's save() method seems to be a pretty common case" -from
[https://groups.google.com/d/msg/django-users/jqgDy4oo5ZQ/KUSz2gyJ8m0J
django-users].
--
Ticket URL: <https://code.djangoproject.com/ticket/22656#comment:3>
* status: assigned => closed
* resolution: => wontfix
Comment:
Agreed with Tim, that's a use case we want to support.
--
Ticket URL: <https://code.djangoproject.com/ticket/22656#comment:4>
Comment (by anubhav9042):
Replying to [comment:4 aaugustin]:
> Agreed with Tim, that's a use case we want to support.
I have added this for `ForeignKey` only not for other fields. In others it
is fine but in FK it will create `database errors` on `save()` if any
object is not provided.
If null=False then keeping blank=True for `ForeignKey` is wrong and will
lead to errors in save() as said above. I think that was what I wanted to
say and could not explain earlier.
--
Ticket URL: <https://code.djangoproject.com/ticket/22656#comment:5>
Comment (by anubhav9042):
Replying to [comment:2 aaugustin]:
> I assume you meant "blank=False when null=False" instead of "null=True
with blank=True"?
I meant the case where null=False and blank=True for `ForeignKey`
--
Ticket URL: <https://code.djangoproject.com/ticket/22656#comment:6>
Comment (by timo):
As noted in #13776, the use case worked in Django 1.0, but broke in 1.2.
We should try to fix it rather than just disallow it.
--
Ticket URL: <https://code.djangoproject.com/ticket/22656#comment:7>