﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33151	createsuperuser doesn't work in non-interactive mode if a ManyToManyField is in REQUIRED_FIELDS.	Christophe Henry	Christophe Henry	"#21755 added `ForeignKey` support to `REQUIRED_FIELDS` in `createsuperuser` command but this support is not working in non-interactive mode.

The buggy line is [https://github.com/django/django/blob/main/django/contrib/auth/management/commands/createsuperuser.py#L187 this line]. If `value` is an integer, `field.clean()` simply returns it after validation while [https://github.com/django/django/blob/main/django/contrib/auth/management/commands/createsuperuser.py#L189 `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 [https://github.com/django/django/blob/main/django/db/models/fields/__init__.py#L670 `ForeignKey.to_python()`] expects an integer.

There may be the same problem with `ManyToManyField`."	Bug	closed	contrib.auth	3.1	Normal	fixed		Hasan Ramezani	Ready for checkin	1	0	0	0	0	0
