#34542: Required fields allowed to be blank are not accepted non-interactively
using createsuperuser
-------------------------------------+-------------------------------------
     Reporter:  Lantizia             |                    Owner:  Anvansh
                                     |  Singh
         Type:  Bug                  |                   Status:  assigned
    Component:  contrib.auth         |                  Version:  dev
     Severity:  Normal               |               Resolution:
     Keywords:  auth                 |             Triage Stage:  Accepted
  createsuperuser superuser email    |
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by SyedMa3):

 Replying to [ticket:34542 Lantizia]:
 > 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 these lines...
 [https://github.com/django/django/blob/main/django/contrib/auth/models.py#L378]
 and
 [https://github.com/django/django/blob/main/django/contrib/auth/models.py#L358]
 >
 > The 'email' field is marked as required, but is also marked in a way to
 allow it to be empty.
 >
 > This section of the code validates required fields when createsuperuser
 is called **interactively**...
 
[https://github.com/django/django/blob/main/django/contrib/auth/management/commands/createsuperuser.py#L143]
 >
 > This section of the code validates required fields when createsuperuser
 is called **non-interactively**...
 
[https://github.com/django/django/blob/main/django/contrib/auth/management/commands/createsuperuser.py#L219]
 >
 > Although required fields are enforced, the **non-interactive** code
 doesn't allow for those to be blank, where blank required fields are
 permitted.  I've tried to set a field like 'email' to blank **non-
 interactively** but nothing works, for example...
 >
 > a) just don't set the email field either through an argument or an
 environment variable... it'll 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
 >
 > Hope this makes sense :)


 I just tried making a superuser non-interactively using the command

 `python manage.py createsuperuser --email "" --user admin`

 and it works without any error.

 Is this bug still valid? @Lantizia

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34542#comment:11>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070188c941a31b-3caf6cdf-0fd7-401c-bb10-56596e6b0748-000000%40eu-central-1.amazonses.com.

Reply via email to