Following the documentation: https://docs.djangoproject.com/en/dev/howto/custom-management-commands/
I created my own custom command (called something else but example shown below):
from django.core.management.base import BaseCommand, CommandError
from polls.models import Poll
class Command(BaseCommand):
    args = '<poll_id poll_id ...>'
    help = 'Closes the specified poll for voting'
    def handle(self, *args, **options):
        for poll_id in args:
            try:
                poll = Poll.objects.get(pk=int(poll_id))
            except Poll.DoesNotExist:
                raise CommandError('Poll "%s" does not exist' % poll_id)
            poll.opened = False
            poll.save()
            self.stdout.write('Successfully closed poll "%s"' % poll_id)
        return "Yay"
The question is how come returning a string like "Yay" does not work? Am I doing it wrong or is it not possible?
When I call the custom command from my view, I do something like:
     value = call_command('call_custom_command', parameter)
     print value
but the value is shown to be None.
 
    