from django.core.management.base import BaseCommand, CommandError
from stationspinner.character.models import CharacterSheet

class Command(BaseCommand):
    help = 'Lists all enabled characterIDs with their APIKey PKs. Handy for sending tasks'

    def handle(self, *args, **options):
        characters = CharacterSheet.objects.filter(enabled=True)
        for char in characters:
            self.stdout.write('CharacterID\t\t {0} APIKey\t\t {1}'.format(char.pk, char.owner_key.pk))
from django.core.management.base import BaseCommand, CommandError
from stationspinner.character.models import CharacterSheet

class Command(BaseCommand):
    help = 'Lists all enabled characterIDs with their APIKey PKs. Handy for sending tasks'

    def handle(self, *args, **options):
        characters = CharacterSheet.objects.filter(enabled=True)
        for char in characters:
            self.stdout.write('{0}\t\tCharacterID\t\t {1} APIKey\t\t {2}'.format(char.name,
                                                                          char.pk,
                                                                          char.owner_key.pk))
Simplify the output for copypaste
Simplify the output for copypaste

  from django.core.management.base import BaseCommand, CommandError
  from stationspinner.character.models import CharacterSheet
  
  class Command(BaseCommand):
      help = 'Lists all enabled characterIDs with their APIKey PKs. Handy for sending tasks'
  
      def handle(self, *args, **options):
          characters = CharacterSheet.objects.filter(enabled=True)
          for char in characters:
-             self.stdout.write('CharacterID\t\t {0} APIKey\t\t {1}'.format(char.pk, char.owner_key.pk))
+             self.stdout.write('{0}\t\tCharacterID\t\t {1} APIKey\t\t {2}'.format(char.name,
+                                                                           char.pk,
+                                                                           char.owner_key.pk))
Simplify the output for copypaste
## Code Before:
from django.core.management.base import BaseCommand, CommandError
from stationspinner.character.models import CharacterSheet

class Command(BaseCommand):
    help = 'Lists all enabled characterIDs with their APIKey PKs. Handy for sending tasks'

    def handle(self, *args, **options):
        characters = CharacterSheet.objects.filter(enabled=True)
        for char in characters:
            self.stdout.write('CharacterID\t\t {0} APIKey\t\t {1}'.format(char.pk, char.owner_key.pk))
## Instruction:
Simplify the output for copypaste
## Code After:
from django.core.management.base import BaseCommand, CommandError
from stationspinner.character.models import CharacterSheet

class Command(BaseCommand):
    help = 'Lists all enabled characterIDs with their APIKey PKs. Handy for sending tasks'

    def handle(self, *args, **options):
        characters = CharacterSheet.objects.filter(enabled=True)
        for char in characters:
            self.stdout.write('{0}\t\tCharacterID\t\t {1} APIKey\t\t {2}'.format(char.name,
                                                                          char.pk,
                                                                          char.owner_key.pk))