title: Deploy static assets to heroku from local machine - can't open file 'manage.py': [Errno 2] No such file or directory
body: <p>I am trying deploy my assets files to heroku and I get this output in my command line interface:</p>
  
  <pre><code>(nrb_dev) ➜  neurorehabilitation_projects git:(master) ✗ heroku run python manage.py collectstatic
  Running python manage.py collectstatic on neurorehabilitation.... up, run.5168
  python: can't open file 'manage.py': [Errno 2] No such file or directory
  (nrb_dev) ➜  neurorehabilitation_projects git:(master) ✗ 
  </code></pre>
  
  <p>It's strange for me, due to I am currently in the directory/folder in which the <code>manage.py</code> file is located</p>
  
  <p>With the order to get an application early deployment, I've choose disable the environment variable <code>DISABLE_COLLECT_STATIC</code> of this way:</p>
  
  <pre><code>(nrb_dev) ➜  neurorehabilitation_projects git:(master) ✗ heroku config:set DISABLE_COLLECTSTATIC=1
  Setting config vars and restarting neurorehabilitation... done
  DISABLE_COLLECTSTATIC: 1
  (nrb_dev) ➜  neurorehabilitation_projects git:(master)
  </code></pre>
  
  <p>According to the above, when I perform <code>git push heroku master</code> I can deploy mi application:</p>
  
  <pre><code>remote: 
  remote: 
  remote: -----&gt; Discovering process types
  remote:        Procfile declares types -&gt; web
  remote: 
  remote: -----&gt; Compressing...
  remote:        Done: 46M
  remote: -----&gt; Launching...
  remote:        Released v15
  remote:        https://neurorehabilitation.herokuapp.com/ deployed to Heroku
  remote: 
  remote: Verifying deploy... done.
  To https://git.heroku.com/neurorehabilitation.git
   * [new branch]      master -&gt; master
  (nrb_dev) ➜  neurorehabilitation_projects git:(master) ✗
  </code></pre>
  
  <p>According to the previous actions, in my main link <a href="https://neurorehabilitation.herokuapp.com/" rel="nofollow noreferrer">https://neurorehabilitation.herokuapp.com/</a> there is an error, I guess that it's because the static files des not were sent and were disabled. </p>
  
  <p>Is this right? I don't know ...</p>
  
  <p>But, something that seem strange is that in my Django Admin <a href="https://neurorehabilitation.herokuapp.com/admin/" rel="nofollow noreferrer">https://neurorehabilitation.herokuapp.com/admin/</a>  I can detail the template and the css styles and js in the admin, then, I unknown if heroku is working with static files or not.</p>
  
  <p>What happened here int this situation with my static files?</p>
  
  <p>However, I follow my process, and in this opportunity I can deploy remotely to heroku actions related with the <code>manage.py</code> commands.</p>
  
  <p>I've checked this because I can execute my migrations of my application:</p>
  
  <pre><code>(nrb_dev) ➜  neurorehabilitation_projects git:(master) ✗ heroku run python  manage.py migrate        
  Running python manage.py migrate on neurorehabilitation.... up, run.7836
  Operations to perform:
    Apply all migrations: contenttypes, auth, userprofiles, sessions, medical_encounter_information, admin
  Running migrations:
    Rendering model states... DONE
    Applying contenttypes.0001_initial... OK
    Applying contenttypes.0002_remove_content_type_name... OK
    Applying auth.0001_initial... OK
    Applying auth.0002_alter_permission_name_max_length... OK
    Applying auth.0003_alter_user_email_max_length... OK
    Applying auth.0004_alter_user_username_opts... OK
    Applying auth.0005_alter_user_last_login_null... OK
    Applying auth.0006_require_contenttypes_0002... OK
    Applying auth.0007_alter_validators_add_error_messages... OK
    Applying userprofiles.0001_initial... OK
    Applying admin.0001_initial... OK
    Applying admin.0002_logentry_remove_auto_add... OK
    Applying userprofiles.0002_auto_20160225_2130... OK
    Applying userprofiles.0003_auto_20160225_2130... OK
    Applying medical_encounter_information.0001_initial... OK
    Applying medical_encounter_information.0002_auto_20160225_2130... OK
    Applying medical_encounter_information.0003_auto_20160225_2130... OK
    Applying medical_encounter_information.0004_auto_20160225_2211... OK
    Applying medical_encounter_information.0005_auto_20160225_2211... OK
    Applying medical_encounter_information.0006_auto_20160225_2303... OK
    Applying medical_encounter_information.0007_auto_20160229_2204... OK
    Applying medical_encounter_information.0008_auto_20160229_2208... OK
    Applying medical_encounter_information.0009_auto_20160301_0130... OK
    Applying medical_encounter_information.0010_auto_20160301_0312... OK
    Applying medical_encounter_information.0011_auto_20160301_1525... OK
    Applying medical_encounter_information.0012_auto_20160301_1601... OK
    Applying medical_encounter_information.0013_auto_20160301_1606... OK
    Applying medical_encounter_information.0014_auto_20160301_1629... OK
    Applying medical_encounter_information.0015_auto_20160301_1633... OK
    Applying medical_encounter_information.0016_auto_20160301_1636... OK
    Applying sessions.0001_initial... OK
    Applying userprofiles.0004_auto_20160225_2211... OK
    Applying userprofiles.0005_auto_20160225_2211... OK
    Applying userprofiles.0006_auto_20160225_2303... OK
    Applying userprofiles.0007_auto_20160229_2204... OK
    Applying userprofiles.0008_auto_20160229_2208... OK
    Applying userprofiles.0009_auto_20160301_0130... OK
    Applying userprofiles.0010_auto_20160301_0312... OK
    Applying userprofiles.0011_auto_20160301_1525... OK
    Applying userprofiles.0012_auto_20160301_1601... OK
    Applying userprofiles.0013_auto_20160301_1606... OK
    Applying userprofiles.0014_auto_20160301_1629... OK
    Applying userprofiles.0015_auto_20160301_1633... OK
    Applying userprofiles.0016_auto_20160301_1636... OK
  (nrb_dev) ➜  neurorehabilitation_projects git:(master)
  </code></pre>
  
  <p>Also, I ccan create inside my deployed application a superuser from my local toolbet ...</p>
  
  <pre><code>(nrb_dev) ➜  neurorehabilitation_projects git:(master) ✗ heroku run python  manage.py createsuperuser
  Running python manage.py createsuperuser on neurorehabilitation.... up, run.5381
  
  Username: bgarcial
  Email address: bgarcial@sample.com
  Password: 
  Password (again): 
  Superuser created successfully.
  (nrb_dev) ➜  neurorehabilitation_projects git:(master) ✗ 
  </code></pre>
  
  <p>After, I've disabled the environment variable setup previously <code>DISABLE_COLLECTSTATIC=1</code> (<strong>I've delete the environment variable from my settings dashboard heroku application</strong>)</p>
  
  <p>But, wen I execute again the <code>heroku run python  manage.py collectstatic</code> command, I get this notification:</p>
  
  <pre><code>(nrb_dev) ➜  neurorehabilitation_projects git:(master) ✗ heroku run python  manage.py collectstatic
  Running python manage.py collectstatic on neurorehabilitation.... up, run.9342
  
  You have requested to collect static files at the destination
  location as specified in your settings.
  
  This will overwrite existing files!
  Are you sure you want to do this?
  
  Type 'yes' to continue, or 'no' to cancel: yes
  Traceback (most recent call last):
    File "manage.py", line 10, in &lt;module&gt;
      execute_from_command_line(sys.argv)
    File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
      utility.execute()
    File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/__init__.py", line 345, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/base.py", line 348, in run_from_argv
      self.execute(*args, **cmd_options)
    File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/base.py", line 399, in execute
      output = self.handle(*args, **options)
    File "/app/.heroku/python/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 176, in handle
      collected = self.collect()
    File "/app/.heroku/python/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 98, in collect
      for path, storage in finder.list(self.ignore_patterns):
    File "/app/.heroku/python/lib/python3.4/site-packages/django/contrib/staticfiles/finders.py", line 112, in list
      for path in utils.get_files(storage, ignore_patterns):
    File "/app/.heroku/python/lib/python3.4/site-packages/django/contrib/staticfiles/utils.py", line 28, in get_files
      directories, files = storage.listdir(location)
    File "/app/.heroku/python/lib/python3.4/site-packages/django/core/files/storage.py", line 299, in listdir
      for entry in os.listdir(path):
  FileNotFoundError: [Errno 2] No such file or directory: '/app/neurorehabilitation/settings/static'
  (nrb_dev) ➜  neurorehabilitation_projects git:(master) ✗
  </code></pre>
  
  <p>Checking this inconvenient, I guess that my error is here at the end:</p>
  
  <pre><code>directories, files = storage.listdir(location)
        File "/app/.heroku/python/lib/python3.4/site-packages/django/core/files/storage.py", line 299, in listdir
          for entry in os.listdir(path):
      FileNotFoundError: [Errno 2] No such file or directory: '/app/neurorehabilitation/settings/static'
  </code></pre>
  
  <p>And, this tell me that in my heroku application deployed does not exist the <code>static</code> directory </p>
  
  <p>I've executed <code>heroku run bash</code> for check the structure directory inside my heroku application and I can detail the root project named <code>/app</code> in heroku</p>
  
  <pre><code>(nrb_dev) ➜  neurorehabilitation_projects git:(master) ✗ heroku run bash    
      Running bash on neurorehabilitation.... up, run.5840
      ~ $ pwd 
      /app
      ~ $ 
  </code></pre>
  
  <p>I listed the <code>/app</code> content and I see all my directories and files of a similar way like I have in my development local environment django project</p>
  
  <pre><code>~ $ ls
  avatars  custom_storages.py  django-multiselectfield-0.1.3.tar.gz  functional_tests  manage.py  medical_encounter_information  neurorehabilitation  Procfile  requirements  requirements.txt  runtime.txt  userprofiles
  </code></pre>
  
  <p>With my error is related with this subject:</p>
  
  <p>FileNotFoundError: [Errno 2] No such file or directory: '/app/neurorehabilitation/settings/static'</p>
  
  <p>Then I enter to these directory <code>/app/neurorehabilitation/settings/</code> but I can see that does not exist a directory named <code>static</code> inside, that is the way  as heroku try search:</p>
  
  <pre><code>~ $ cd /app/neurorehabilitation/settings/
  ~/neurorehabilitation/settings $ ls
  base.py  development.py  __init__.py  production.py  staging.py  testing.py
  ~/neurorehabilitation/settings $
  </code></pre>
  
  <p>And this is because according to the structure directory that I setup when I create my django project in my local development environment.
  I define the following:</p>
  
  <p><a href="https://i.stack.imgur.com/PrAJU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PrAJU.png" alt="enter image description here"></a></p>
  
  <p>Then, according to the previous situation ...</p>
  
  <p>Why git when I perform deployment to heroku, the process is searching a path to <code>neurorehabilitation/settings/static</code> when this is not setup from the originar sproject source, this mean, my project in my machine before to deploy to heroku?</p>
  
  <p>What action could I take about it?
  Heroku platform, when I execute the <code>heroku run python manage.py collectstatic</code> command this try search a directory taht does not exist or not is setup in the structure directory of my project?</p>
  
  <p>Even I try create the <code>/app/neurorehabilitation/settings/static</code>folder via <code>heroku run bash</code>, but this not works </p>
  
  <pre><code>(nrb_dev) ➜  neurorehabilitation_projects git:(master) ✗ heroku run bash
  Running bash on test-nrb.... up, run.1604
  ~ $ cd neurorehabilitation/settings/
  ~/neurorehabilitation/settings $ mkdir static
  ~/neurorehabilitation/settings $ ls -all
  total 36
  drwx------ 3 u51683 dyno 4096 Apr  1 15:07 .
  drwx------ 5 u51683 dyno 4096 Apr  1 15:02 ..
  -rw------- 1 u51683 dyno 8106 Apr  1 15:02 base.py
  -rw------- 1 u51683 dyno  684 Apr  1 15:02 development.py
  -rw------- 1 u51683 dyno    0 Apr  1 15:02 __init__.py
  -rw------- 1 u51683 dyno  930 Apr  1 15:02 production.py
  -rw------- 1 u51683 dyno  530 Apr  1 15:02 staging.py
  drwx------ 2 u51683 dyno 4096 Apr  1 15:07 static
  -rw------- 1 u51683 dyno  488 Apr  1 15:02 testing.py
  ~/neurorehabilitation/settings $ exit
  exit
  (nrb_dev) ➜  neurorehabilitation_projects git:(master) ✗ heroku run python manage.py collectstatic
  Running python manage.py collectstatic on test-nrb.... up, run.5358
  
  You have requested to collect static files at the destination
  location as specified in your settings.
  
  This will overwrite existing files!
  Are you sure you want to do this?
  
  Type 'yes' to continue, or 'no' to cancel: yes
  Traceback (most recent call last):
    File "manage.py", line 10, in &lt;module&gt;
      execute_from_command_line(sys.argv)
    File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
      utility.execute()
    File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/__init__.py", line 345, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/base.py", line 348, in run_from_argv
      self.execute(*args, **cmd_options)
    File "/app/.heroku/python/lib/python3.4/site-packages/django/core/management/base.py", line 399, in execute
      output = self.handle(*args, **options)
    File "/app/.heroku/python/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 176, in handle
      collected = self.collect()
    File "/app/.heroku/python/lib/python3.4/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 98, in collect
      for path, storage in finder.list(self.ignore_patterns):
    File "/app/.heroku/python/lib/python3.4/site-packages/django/contrib/staticfiles/finders.py", line 112, in list
      for path in utils.get_files(storage, ignore_patterns):
    File "/app/.heroku/python/lib/python3.4/site-packages/django/contrib/staticfiles/utils.py", line 28, in get_files
      directories, files = storage.listdir(location)
    File "/app/.heroku/python/lib/python3.4/site-packages/django/core/files/storage.py", line 299, in listdir
      for entry in os.listdir(path):
  FileNotFoundError: [Errno 2] No such file or directory: '/app/neurorehabilitation/settings/static'
  (nrb_dev) ➜  neurorehabilitation_projects git:(master)
  </code></pre>
  
  <p>I unknown how to address this problem, Why in my heroku deployment does not create the structures directory similar to my local project?</p>
  
  <p>Somebody what is the reason about it?</p>
  
  <p>Is possible that in the moment I still not understad well how to works heroku at deployment instant in relation to structure directory and files when these are upload to the platform via <code>git push heroku master</code>?</p>
  
  <p>Any support will be highly appreciated.</p>
  
  <p>Thanks for the orientation :)</p>