createsuperuser doesn't work in non-interactive mode if a ManyToManyField is in REQUIRED_FIELDS.
#21755 added ForeignKey
support to REQUIRED_FIELDS
in createsuperuser
command but this support is not working in non-interactive mode.
The buggy line is this line. If value
is an integer, field.clean()
simply returns it after validation while `create_superuser(**user_data)` on the next line would expect a model instance for the ForeignKey
field.
If you go one step further and override createsuperuser
to pass an instance of the model, then field.clean()
raises an error because `ForeignKey.to_python()` expects an integer.
There may be the same problem with ManyToManyField
.
Change History
(14)
Has patch: |
set
|
Needs tests: |
set
|
Patch needs improvement: |
set
|
Owner: |
changed from nobody to Christophe Henry
|
Status: |
new → assigned
|
Cc: |
Hasan Ramezani added
|
Summary: |
Super user creation always raises an error in non-interactive mode when on required field is a ForeignKey → createsuperuser doesn't work in non-interactive mode if a ManyToManyField/ForeignKey is in REQUIRED_FIELDS.
|
Triage Stage: |
Unreviewed → Accepted
|
Has patch: |
unset
|
Needs tests: |
unset
|
Patch needs improvement: |
unset
|
Patch needs improvement: |
set
|
Summary: |
createsuperuser doesn't work in non-interactive mode if a ManyToManyField/ForeignKey is in REQUIRED_FIELDS. → createsuperuser doesn't work in non-interactive mode if a ManyToManyField is in REQUIRED_FIELDS.
|
Patch needs improvement: |
unset
|
Triage Stage: |
Accepted → Ready for checkin
|
Resolution: |
→ fixed
|
Status: |
assigned → closed
|
Proposed patch to fix the bug