I've only encountered Django once before (installing mailman3), but this
time I was trying to install NetBox and I noticed this sentence in their
documentation...
"Specifying an email address for the user is not required" (search for
that line in the URL below for better context)
[https://docs.netbox.dev/en/stable/installation/3-netbox/]
According to this line...
[https://github.com/django/django/blob/main/django/contrib/auth/models.py#L378]
The 'email' field is marked required.
However this section of the code (which is when createsuperuser is called
**interactively**)...
[https://github.com/django/django/blob/main/django/contrib/auth/management/commands/createsuperuser.py#L143]
It doesn't look like it's written in a way which can enforce that, as a
result when you run it this way... it lets you to enter nothing for the
email field.
However this section of the code (which is when createsuperuser is called
**non-interactively**)...
[https://github.com/django/django/blob/main/django/contrib/auth/management/commands/createsuperuser.py#L219]
Seems to enforce required fields... and it definitely seems to be doing
that as I've tried the following ways of **not** providing a value for the
email field in the following ways...
a) don't set the email field either through an argument or an environment
variable... it'll still complain it is needed
b) set the email field via a variable as just 'DJANGO_SUPERUSER_EMAIL='
(i.e. setting the variable to null)... it still complains it is needed
c) set the email field via an argument of '--email ""' (i.e. double
quotes) or '--email ''' (i.e. double single quotes) or even '--email \ '
(i.e. passing a single space)... it still complains it is needed
So it seems to be that... as least **non-interactively** it is doing what
it is supposed to... and making the 'required' field of 'email' non-
optional. But **interactively** it is failing to do this.
If that is right then the NetBox documentation is wrong (and I can let
them know about that) as it would only be accidental that you're capable
of not setting an email address for the superuser when using
createsuperuser interactively.
Hope this makes sense :)
--
Ticket URL: <https://code.djangoproject.com/ticket/34542>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
New description:
[https://docs.netbox.dev/en/stable/installation/3-netbox/]
--
--
Ticket URL: <https://code.djangoproject.com/ticket/34542#comment:1>
* status: new => closed
* resolution: => invalid
Comment:
Hello! The email field for the provided User class from
django.contrib.auth does indeed require the email. But the email is
allowed to be the empty string (`blank=True` in the model), so when
creating users via a django web form or interactively, one can pass the
empty string as value and that is accepted.
In summary, the email field is required but it can be blank.
--
Ticket URL: <https://code.djangoproject.com/ticket/34542#comment:2>
Comment (by Lantizia):
Hi, then the bug is that noninteractively... it is not allowed to be
blank.
--
Ticket URL: <https://code.djangoproject.com/ticket/34542#comment:3>
* status: closed => new
* resolution: invalid =>
--
Ticket URL: <https://code.djangoproject.com/ticket/34542#comment:4>