{"record":{"id":"37ca65bae354d4ec","repo":"django/django","slug":"subclasses-of-labelcommand-must-provide-a-handle-l","errorCode":null,"errorMessage":"subclasses of LabelCommand must provide a handle_label() method","messagePattern":"subclasses of LabelCommand must provide a handle_label\\(\\) method","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"django/core/management/base.py","lineNumber":716,"sourceCode":"            self.missing_args_message = self.missing_args_message % self.label\n\n    def add_arguments(self, parser):\n        parser.add_argument(\"args\", metavar=self.label, nargs=\"+\")\n\n    def handle(self, *labels, **options):\n        output = []\n        for label in labels:\n            label_output = self.handle_label(label, **options)\n            if label_output:\n                output.append(label_output)\n        return \"\\n\".join(output)\n\n    def handle_label(self, label, **options):\n        \"\"\"\n        Perform the command's actions for ``label``, which will be the\n        string as given on the command line.\n        \"\"\"\n        raise NotImplementedError(\n            \"subclasses of LabelCommand must provide a handle_label() method\"\n        )\n","sourceCodeStart":698,"sourceCodeEnd":719,"githubUrl":"https://github.com/django/django/blob/ae25a40be07e8a749edf526df37c93e59d4a22c9/django/core/management/base.py#L698-L719","documentation":"Raised by LabelCommand.handle_label (django/core/management/base.py:716) as a NotImplementedError because LabelCommand delegates per-label work to handle_label, which is abstract. Subclasses must override it; the base method exists only to fail loudly. It fires when a LabelCommand subclass is invoked without overriding this method and at least one label argument is provided.","triggerScenarios":"Subclassing LabelCommand (e.g. for a command operating on file paths or other string labels) but not implementing handle_label(self, label, **options), then running the command with one or more label arguments.","commonSituations":"Scaffolding a new LabelCommand and leaving the method unimplemented; renaming it; confusing it with AppCommand's handle_app_config.","solutions":["Implement def handle_label(self, label, **options): in your LabelCommand subclass.","If the labels should be installed apps, subclass AppCommand and implement handle_app_config instead.","Confirm exact method name and signature (handle_label, with label as first positional arg)."],"exampleFix":"# before\nclass Command(LabelCommand):\n    label = 'filename'\n# after\nclass Command(LabelCommand):\n    label = 'filename'\n    def handle_label(self, label, **options):\n        self.stdout.write('processing %s' % label)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def label_command_implemented(cmd_cls):\n    return callable(getattr(cmd_cls, 'handle_label', None)) and \\\n           cmd_cls.handle_label is not LabelCommand.handle_label","tryCatchPattern":null,"preventionTips":["Use startcommand or a snippet that includes handle_label.","Smoke-test LabelCommand subclasses by invoking with a sample label."],"tags":["django","management-command","abstract-method","not-implemented"],"analyzedSha":"ae25a40be07e8a749edf526df37c93e59d4a22c9","analyzedAt":"2026-08-06T21:46:51.801Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}