Wednesday, August 26, 2015

Re: ForeignKey Fields null=True does not imply blank=True

On 26 Aug 2:59, khoobks wrote:
> Hi All,

Hello!

> To me, this seems like an unnecessary trap for users of the Django
> Framework. However there may be a design decision here and I'd love to be
> educated on why there would be a situation where it makes sense for
> null=True and blank=False.

Well, maybe it's useful if you want to be able to programmatically
(a.k.a. in the backend, or with a management command, maybe even called
by a cronjob) create some objects with that FK set to NULL (probably
because in your case you cannot possibly know how to set it), but you
want to force the user to specify a value when updating them (so in that
moment the blank=True will enforce this behaviour).

> Regards
> Ben

Regards,
Mark

--
. ''`. | GPG Public Key : 0xCD542422 - Download it from http://is.gd/fOa7Vm
: :' : | GPG Fingerprint : 0823 A40D F31B 67A8 5621 AD32 E293 A2EB CD54 2422
`. `'` | Powered by Debian GNU/Linux, http://www.debian.org
`- | Try not. Do, or do not. There is no try. - Master Yoda, TESB.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20150826124840.GA25933%40sheldon.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment