def handle(self, *args, **options):
    all_entries = MyModel.objects.all()
for entry in all_entries:
    self.stdout.write('entry "%s"' % entry)
Running a standalone script doing a model query in Django with `settings/dev.py` instead of `settings.py`