Changes between Version 1 and Version 5 of Ticket #34542


Ignore:
Timestamp:
May 9, 2023, 12:38:04 AM (12 months ago)
Author:
Lantizia
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #34542

    • Property Summary Required fields not enforced when interactively using createsuperuserRequired fields allowed to be blank are not accepted non-interactively using createsuperuser
  • Ticket #34542 – Description

    v1 v5  
    1 Disclaimer: I really don't know much about Django... so I might be completely wrong on this.
    2 
    31I'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...
    42
     
    97According to this line... [https://github.com/django/django/blob/main/django/contrib/auth/models.py#L378]
    108
    11 The 'email' field is marked required.
     9The 'email' field is marked as required, but is also marked in a way to allow it to be empty.
    1210
    13 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]
     11This is the section of the code that deals with validating required fields when createsuperuser is called **interactively**... [https://github.com/django/django/blob/main/django/contrib/auth/management/commands/createsuperuser.py#L143]
    1412
    15 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.
     13This is the section of the code that deals with validating required fields when createsuperuser is called **non-interactively**... [https://github.com/django/django/blob/main/django/contrib/auth/management/commands/createsuperuser.py#L219]
    1614
    17 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]
     15Although 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...
    1816
    19 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...
    20 
    21 a) don't set the email field either through an argument or an environment variable... it'll still complain it is needed
     17a) just don't set the email field either through an argument or an environment variable... it'll complain it is needed
    2218b) 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
    2319c) 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
    2420
    25 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.
    26 
    27 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.
    28 
    2921Hope this makes sense :)
Back to Top