title: Attribute Error: 'dict' object has no attribute 'endswith'
body: <pre><code>(y) xlm@d8cb8a102c73:~/workspace/y-server/y$ ./manage.py 
   run_algorithm --settings=y.settings.local
  Traceback (most recent call last):
    File "./manage.py", line 10, in &lt;module&gt;
      execute_from_command_line(sys.argv)
    File "/home/xlm/.virtualenvs/y/lib/python3.5/site- 
  packages/django/core/management/__init__.py", line 354, in 
  execute_from_command_line
      utility.execute()
    File "/home/xlm/.virtualenvs/y/lib/python3.5/site- 
  packages/django/core/management/__init__.py", line 346, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/home/xlm/.virtualenvs/y/lib/python3.5/site- 
  packages/django/core/management/base.py", line 394, in run_from_argv
      self.execute(*args, **cmd_options)
    File "/home/xlm/.virtualenvs/y/lib/python3.5/site- 
  packages/django/core/management/base.py", line 454, in execute
      self.stdout.write(output)
    File "/home/xlm/.virtualenvs/y/lib/python3.5/site- 
  packages/django/core/management/base.py", line 111, in write
      if ending and not msg.endswith(ending):
  AttributeError: 'dict' object has no attribute 'endswith'
  </code></pre>
  
  <p>I am trying to run the file algorithm.py with the command file run_algorithm.py (below) on a django framework. However I get the above attribute error, and I am unsure why.</p>
  
  <pre><code>import logging
  from django.conf import settings
  from django.core.management.base import BaseCommand
  from ...algorithm import engagement_level_mapping
  logger = logging.getLogger(settings.LOGGER_NAME)
  
  
  class Command(BaseCommand):
       help = "TODO: describe"
       def handle(self, *args, **options):
          result = engagement_level_mapping()
          return result
  </code></pre>
  
  <p>However, when printing the result, rather than returning, the file executes correctly.</p>
  
  <pre><code>import logging
  from django.conf import settings
  from django.core.management.base import BaseCommand
  from ...algorithm import engagement_level_mapping
  logger = logging.getLogger(settings.LOGGER_NAME)
  
  
  class Command(BaseCommand):
       help = "TODO: describe"
       def handle(self, *args, **options):
          result = engagement_level_mapping()
          print(result)
  </code></pre>
  
  <p>The command file prints a dictionary of engagement values for each user (not that relevant, but just that it prints a dictionary).</p>
  
  <p>Here is the code in base.py</p>