6 | | I glanced through the source code, and it looks like `django.core.management.base.BaseCommand` handles the `--force-color` option by setting `self.style = color_style(force_color)`. Then the specific commands which inherit from `BaseCommand`, like `migrate`, use `self.style` when writing to stdout. However, `runserver`, while inheriting from `BaseCommand`, doesn't ever reference `self.style`, nor does it do anything else with `--force-color`. Instead, the `style` object is defined in `django.utils.log.ServerFormatter` as `self.style = color_style()`, so `force_color` is ''never'' `True` regardless of any environment variables. That is why I said in my original comment that the current way to solve this is to override `ServerFormatter`, but it seems like Django could support `--force-color` for `runserver`, perhaps by setting an environment variable that is picked up by the default `ServerFormatter`? Or if there are reasons not to do this, then perhaps the documentation should be updated to note that `runserver` does not support `--force-color`. |
| 6 | I glanced through the source code, and it looks like `django.core.management.base.BaseCommand` handles the `--force-color` option by setting `self.style = color_style(force_color)`. Then the specific commands which inherit from `BaseCommand`, like `migrate`, use `self.style` when writing to stdout. However, `runserver`, while inheriting from `BaseCommand`, doesn't ever reference `self.style`, nor does it do anything else with `--force-color`. Instead, the `style` object is defined in `django.utils.log.ServerFormatter` as `self.style = color_style()`, so `force_color` is ''never'' `True` regardless of any environment variables. That is why I said in my original comment that the current way to solve this is to override `ServerFormatter`, but it seems like Django could support `--force-color` for `runserver`, perhaps by setting an environment variable that is picked up by the default `ServerFormatter`. Or if there are reasons not to do this, then perhaps the documentation should be updated to note that `runserver` does not support `--force-color`. |