diff --git a/django/core/management/base.py b/django/core/management/base.py
index 2f8664f..3419595 100644
a
|
b
|
class BaseCommand(object):
|
487 | 487 | if any(e.is_serious() and not e.is_silenced() for e in all_issues): |
488 | 488 | raise CommandError(msg) |
489 | 489 | elif msg and visible_issue_count: |
490 | | self.stderr.write(msg) |
| 490 | # self.stderr is not guaranteed to be set here |
| 491 | stderr = getattr(self, 'stderr', OutputWrapper(sys.stderr, self.style.ERROR)) |
| 492 | stderr.write(msg) |
| 493 | |
491 | 494 | elif msg: |
492 | | self.stdout.write(msg) |
| 495 | # self.stdout is not guaranteed to be set here |
| 496 | stdout = getattr(self, 'stdout', OutputWrapper(sys.stdout)) |
| 497 | stdout.write(msg) |
493 | 498 | |
494 | 499 | def handle(self, *args, **options): |
495 | 500 | """ |