Re: Django models `EmailField` default is empty string - Not `None` (or Null) . Why ?

2021-06-14 Thread Aymeric Augustin
Hello,

https://docs.djangoproject.com/en/3.2/ref/models/fields/#django.db.models.Field.null
 

 should clarify the situation.

-- 
Aymeric.



> On 13 Jun 2021, at 13:17, Carlos Leite  wrote:
> 
> 
> Yesterday I realized that, Django email field default value is not "Null" 
> actually is an empty string ("")  - Although I'm not code often, I was 
> surprised.
> 
> I wrote some tests for a model where an  `emailfield` was supposed to be 
> `null=False`. 
> 
> But during the tests, it didn't raise an Exception (when persist on DB). Or 
> for a ModelForm `is_valid` in fact was True.
> 
> I did some (not a lot) research, and it seems the default value for an empty 
> value for EmailField is ""
> Isn't it counter productive? (at least for me, it was)
> I believe, the empty value,  is a special case for a Model Field 
> and I couldn't find any  information on docs. (I told I did SOME research) 
> I did check 
> https://docs.djangoproject.com/en/3.2/ref/models/fields/#emailfield 
> 
> 
> Please let me know my expectations make sense, I'll do my best for help, 
> if not, I know its not the place for "help", just tell me I'm wrong. 
> 
> Thanks everyone.
> 
> 
> Cadu Leite
> | Twitter 
> | @cadu_leite 
> 
> http://people.python.org.br/ 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-developers+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-developers/CAEM6-Q%2B1VHddFaXWNFgdd3fU%2B1BHOVo0U%3De-SOt2-ptFq24CcQ%40mail.gmail.com
>  
> .

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/BDFE41D4-0087-4EA3-970D-3F20D0C30502%40polytechnique.org.


Django models `EmailField` default is empty string - Not `None` (or Null) . Why ?

2021-06-13 Thread Carlos Leite
Yesterday I realized that, Django email field default value is not "Null"
actually is an empty string ("")  - Although I'm not code often, I was
surprised.

I wrote some tests for a model where an  `emailfield` was supposed to be
`null=False`.

But during the tests, it didn't raise an Exception (when persist on DB). Or
for a ModelForm `is_valid` in fact was True.

I did some (not a lot) research, and it seems the default value for an
empty value for EmailField is ""
Isn't it counter productive? (at least for me, it was)
I believe, the empty value,  is a special case for a Model Field
and I couldn't find any  information on docs. (I told I did SOME research)
I did check
https://docs.djangoproject.com/en/3.2/ref/models/fields/#emailfield

Please let me know my expectations make sense, I'll do my best for help,
if not, I know its not the place for "help", just tell me I'm wrong.

Thanks everyone.


Cadu Leite
| Twitter
| @cadu_leite 

http://people.python.org.br/

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAEM6-Q%2B1VHddFaXWNFgdd3fU%2B1BHOVo0U%3De-SOt2-ptFq24CcQ%40mail.gmail.com.