title: Django custom management commands: AttributeError: 'module' object has no attribute 'Command'
body: <p>I am trying to make a custom management command as show in the docs here: <a href="https://docs.djangoproject.com/en/dev/howto/custom-management-commands/">https://docs.djangoproject.com/en/dev/howto/custom-management-commands/</a></p>
  
  <p>When I try to run the command from my project directory I am experiencing the following error:</p>
  
  <pre><code>AttributeError: 'module' object has no attribute 'Command'
  </code></pre>
  
  <p>Here is the file:</p>
  
  <pre><code>#event_expiration.py
  from django.core.management.base import BaseCommand, CommandError
  from app.models import Event
  import datetime
  
  class Command(BaseCommand):
      help = 'deletes expired events'
  
      def handle(self, *args, **options):
  
          today = datetime.datetime.now()
          events = Event.objects.filter(date=datetime.date(2011,11,11))
  
          for e in events:
              e.delete()
  
          self.stdout.write('Expired events successfully deleted.')
  </code></pre>
  
  <p>The command I am running is :</p>
  
  <pre><code>$ python manage.py event_expiration
  </code></pre>
  
  <p>I've made sure I am adding the event_expiration.py file within management and commands folders and that those folders have init files. those are in one of my app folders.</p>
  
  <p>Am I overlooking something here? Any help is appreciated, thanks!</p>
  
  <p>EDIT:</p>
  
  <p>Fellow SO user Yuji helped me attempt to debug this a bit but we are still stumped. heres what we did:</p>
  
  <p>First, the full traceback and command:</p>
  
  <pre><code>(venv)matt@inspirion14z:~/Dropbox/PROD/ersvp.it$ python manage.py event_expiration
  Traceback (most recent call last):
    File "manage.py", line 10, in &lt;module&gt;
      execute_from_command_line(sys.argv)
    File "/home/matt/Dropbox/PROD/ersvp.it/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 443, in execute_from_command_line
      utility.execute()
    File "/home/matt/Dropbox/PROD/ersvp.it/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 382, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/home/matt/Dropbox/PROD/ersvp.it/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
      klass = load_command_class(app_name, subcommand)
    File "/home/matt/Dropbox/PROD/ersvp.it/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 70, in load_command_class
      return module.Command()
  AttributeError: 'module' object has no attribute 'Command'
  </code></pre>
  
  <p>To see what was going on at django/core/management/<strong>init</strong>.py", line 70 I placed import pdb; pdb.set_trace() within the file.</p>
  
  <p>While in debug mode we tried: </p>
  
  <pre><code>module.__file__ 
  </code></pre>
  
  <p>to check if the module was where expected, and it indeed was, with an output of:</p>
  
  <pre><code>'/home/matt/Dropbox/PROD/ersvp.it/app/management/commands/event_expiration.pyc'
  </code></pre>
  
  <p>Next, we tried manually importing Command in the shell:</p>
  
  <pre><code>&gt;&gt;&gt; from app.management.commands.event_expiration import Command 
  Traceback (most recent call last):   File "&lt;console&gt;", line 1, in &lt;module&gt; ImportError: cannot import name Command
  </code></pre>
  
  <p>Still scratching my head!</p>