Discussion:
Boolean Field should have allow_false (default=True) attribute
Tanjim Hossain
6 years ago
Permalink
I was trying to create 'EmailAddress' model to store multiple emails for an
'user'. The model has and 'is_primary' field with null=True and
unique_together = ('user', 'is_primary')
So if EmailAddress Instance has is_primary set to false, only one primary
email can be set for each user; And that's exactly I want.
but using validator with is_primary(BooleanField) is too much messy work to
do, No!?
Django should come with something like 'allow_false' by default for only
BooleanField
--
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+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7cf93d1c-2115-4165-b412-367e8decd4c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jason
6 years ago
Permalink
If I understand you right, you want to have multiple emails for a user, but
only one set to primary, but are running into validation errors if a user
has more than one email that is non-primary?

you can set a boolean field to false in default, but I can't see why this
is django's fault? sounds like you're working with a set of requirements
somewhat unique to your project and need custom validation to make sure its
working.

according to the docs on BooleanField,
https://docs.djangoproject.com/en/2.1/ref/models/fields/#booleanfield, if
you don't set a default, it is None by default. That's fairly clear there
and makes sense by following the principle of least surprise
https://en.wikipedia.org/wiki/Principle_of_least_astonishment
--
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+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9dd60b24-c5db-4d54-bdeb-352c48638df5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Search results for 'Boolean Field should have allow_false (default=True) attribute' (Questions and Answers)
5
replies
can i get question answer of asp.net ?
started 18 years ago
software
Loading...