Repository: django/django
Issue category: Feature Request

`LabelCommand`: `label` does not affect the `missing_args_message`
Description
	 
The missing_args_message attribute of the django.core.management.base.LabelCommand is hard coded using the default value of label = "label".
I would suggest the following update:
class LabelCommand(BaseCommand):
	label = "label"
	missing_args_message = "Enter at least one %s."
	def __init__(self, *args, **kwargs):
		super().__init__(*args, **kwargs)
		
		self.missing_args_message = (
			(missing_args_message % self.label)
			if (missing_args_message := self.missing_args_message) is not None
			else None
		) 
Of course, I am open to refactoring - a single, complex though, conditional assignment allows for avoiding branching.
It can be tested by updating the test_label_command_no_label case.


Functions to edit:
django/core/management/base.py:LabelCommand
Functions added: django/core/management/base.py:LabelCommand.__init__
django/core/management/base.py:LabelCommand

Patch:
diff --git a/django/core/management/base.py b/django/core/management/base.py
index 41b17a24c868..6232b42bd4d2 100644
--- a/django/core/management/base.py
+++ b/django/core/management/base.py
@@ -672,7 +672,13 @@ class LabelCommand(BaseCommand):
     """
 
     label = "label"
-    missing_args_message = "Enter at least one %s." % label
+    missing_args_message = "Enter at least one %s."
+
+    def __init__(self, *args, **kwargs):
+        super().__init__(*args, **kwargs)
+
+        if self.missing_args_message == LabelCommand.missing_args_message:
+            self.missing_args_message = self.missing_args_message % self.label
 
     def add_arguments(self, parser):
         parser.add_argument("args", metavar=self.label, nargs="+")

Test patch: diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index 5ee3eeb80336..29023b74c3ba 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -25,6 +25,7 @@
     color,
     execute_from_command_line,
 )
+from django.core.management.base import LabelCommand
 from django.core.management.commands.loaddata import Command as LoaddataCommand
 from django.core.management.commands.runserver import Command as RunserverCommand
 from django.core.management.commands.testserver import Command as TestserverCommand
@@ -2280,6 +2281,20 @@ def test_label_command_multiple_label(self):
             "('settings', None), ('traceback', False), ('verbosity', 1)]",
         )
 
+    def test_custom_label_command_custom_missing_args_message(self):
+        class Command(LabelCommand):
+            missing_args_message = "Missing argument."
+
+        with self.assertRaisesMessage(CommandError, "Error: Missing argument."):
+            call_command(Command())
+
+    def test_custom_label_command_none_missing_args_message(self):
+        class Command(LabelCommand):
+            missing_args_message = None
+
+        with self.assertRaisesMessage(CommandError, ""):
+            call_command(Command())
+
     def test_suppress_base_options_command_help(self):
         args = ["suppress_base_options_command", "--help"]
         out, err = self.run_manage(args)
diff --git a/tests/staticfiles_tests/test_management.py b/tests/staticfiles_tests/test_management.py
index c0d381738393..1b9179af4958 100644
--- a/tests/staticfiles_tests/test_management.py
+++ b/tests/staticfiles_tests/test_management.py
@@ -124,6 +124,11 @@ def test_all_files_more_verbose(self):
             searched_locations,
         )
 
+    def test_missing_args_message(self):
+        msg = "Enter at least one staticfile."
+        with self.assertRaisesMessage(CommandError, msg):
+            call_command("findstatic")
+
 
 class TestConfiguration(StaticFilesTestCase):
     def test_location_empty(self):