title: Django Celery scheduled task django.core.exceptions.ImproperlyConfigured
body: <p>I am trying to run my scheduled task with the following command:</p>
  
  <pre><code>celery -A Htweetprod2 beat
  </code></pre>
  
  <p>According to Celery 4.0 documentation to start the scheduled task this command should work, yet I am getting this error:</p>
  
  <pre><code>C:\Users\hisg316\Desktop\Htweetprod2&gt;celery -A Htweetprod2 beat
  Traceback (most recent call last):
     File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main
  "__main__", fname, loader, pkg_name)
     File "c:\python27\lib\runpy.py", line 72, in _run_code
  exec code in run_globals
    File "C:\Python27\Scripts\celery.exe\__main__.py", line 9, in &lt;module&gt;
    File "c:\python27\lib\site-packages\celery\__main__.py", line 14, in main
  _main()
    File "c:\python27\lib\site-packages\celery\bin\celery.py", line 326, in main
  cmd.execute_from_commandline(argv)
    File "c:\python27\lib\site-packages\celery\bin\celery.py", line 488, in execute_from_commandline
  super(CeleryCommand, self).execute_from_commandline(argv)))
    File "c:\python27\lib\site-packages\celery\bin\base.py", line 281, in execute_from_commandline
  return self.handle_argv(self.prog_name, argv[1:])
    File "c:\python27\lib\site-packages\celery\bin\celery.py", line 480, in handle_argv
  return self.execute(command, argv)
    File "c:\python27\lib\site-packages\celery\bin\celery.py", line 412, in execute
  ).run_from_argv(self.prog_name, argv[1:], command=argv[0])
    File "c:\python27\lib\site-packages\celery\bin\base.py", line 285, in run_from_argv
  sys.argv if argv is None else argv, command)
    File "c:\python27\lib\site-packages\celery\bin\base.py", line 367, in handle_argv
  *self.parse_options(prog_name, argv, command))
    File "c:\python27\lib\site-packages\celery\bin\base.py", line 403, in parse_options
  self.parser = self.create_parser(prog_name, command)
    File "c:\python27\lib\site-packages\celery\bin\base.py", line 419, in create_parser
  self.add_arguments(parser)
    File "c:\python27\lib\site-packages\celery\bin\beat.py", line 114, in add_arguments
  '-s', '--schedule', default=c.beat_schedule_filename)
    File "c:\python27\lib\site-packages\celery\utils\collections.py", line 130, in __getattr__
  return self[k]
    File "c:\python27\lib\site-packages\celery\utils\collections.py", line 431, in __getitem__
  return getitem(k)
    File "c:\python27\lib\site-packages\celery\utils\collections.py", line 280, in __getitem__
  return mapping[_key]
    File "c:\python27\lib\UserDict.py", line 36, in __getitem__
  if key in self.data:
    File "c:\python27\lib\site-packages\kombu\utils\objects.py", line 44, in __get__
  value = obj.__dict__[self.__name__] = self.__get(obj)
    File "c:\python27\lib\site-packages\celery\app\base.py", line 148, in data
  return self.callback()
    File "c:\python27\lib\site-packages\celery\app\base.py", line 910, in _finalize_pending_conf
  conf = self._conf = self._load_config()
    File "c:\python27\lib\site-packages\celery\app\base.py", line 920, in _load_config
  self.loader.config_from_object(self._config_source)
    File "c:\python27\lib\site-packages\celery\loaders\base.py", line 133, in config_from_object
  self._conf = force_mapping(obj)
    File "c:\python27\lib\site-packages\celery\utils\collections.py", line 52, in force_mapping
  return DictAttribute(m) if not isinstance(m, Mapping) else m
    File "c:\python27\lib\abc.py", line 131, in __instancecheck__
  subclass = getattr(instance, '__class__', None)
    File "c:\python27\lib\site-packages\django\utils\functional.py", line 234, in inner
  self._setup()
    File "c:\python27\lib\site-packages\django\conf\__init__.py", line 39, in _setup
  % (desc, ENVIRONMENT_VARIABLE))
  django.core.exceptions.ImproperlyConfigured: Requested settings, but settings are not configured. You must either define the environment variable 
  DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
  </code></pre>
  
  <p>I have carefully followed the instructions in the documentation and settings are configured to the correct app. Am I missing something?</p>
  
  <p>Here is my <code>tasks.py</code></p>
  
  <pre><code>from celery import Celery
  from Htweets2.models import Htweets2
  from celery.schedules import crontab
  
  app = Celery('Htweetprod2')
  
  @app.task
  def delete_tweets():
      oldtweets = Htweets2.objects.all()
      oldtweets.delete()
  
  CELERYBEAT_SCHEDULE = {
      "delete_tweeets_eachday": {
          'task': "tasks.delete_tweets",
          # Every 1 hour
          'schedule': crontab(hour=1, minute=0),
          'args': (16, 16),
      },
  }
  </code></pre>