title: Deploying a Django Project through Git to Heroku: "No module named.. - failure"
body: <p>I'm hoping you may be able to help me and at the same time, I hope this query may serve others here well in the future.</p>
  
  <p>Based on the excellent book: Python Crash Course by Eric Matthes, I am trying to deploy a Django app to Heroku with the use of Git and have come across several issues. Do note, there are some corrections to the book here: <a href="https://ehmatthes.github.io/pcc/updates.html" rel="nofollow noreferrer">https://ehmatthes.github.io/pcc/updates.html</a> </p>
  
  <p>I am specifically mentioning the book here, as I believe it to be ranked one of the best starter books on various sites, so I can imagine other people facing the same problems - also, as there are several posts related to these 3 topics.</p>
  
  <p>Initially, the app could be commited to Git, but then not pushed to Heroku using: </p>
  
  <blockquote>
    <p><code>git push heroku master</code></p>
  </blockquote>
  
  <p>Part 1:
  This contineously brought about the error: </p>
  
  <pre><code>No Procfile and no package.json file found in Current Directory - See heroku local --help
  </code></pre>
  
  <p>To resolve this, it was vital to make sure the file had no extension (mac os) did not show it, but an ls in the directory showed the .txt ending on the file.</p>
  
  <p>Part 2:
  Retrying this, now allowed for a new message:</p>
  
  <pre><code>ModuleNotFoundError: no module named 'bootstrap3"
  </code></pre>
  
  <p>This could be resolved by making sure the django-bootstrap3==6.x.x requirement was available in the requirements.txt file when the command:</p>
  
  <blockquote>
    <p>pip freeze > requirements.txt</p>
  </blockquote>
  
  <p>was issued - manually adding it did not do the trick.
  In addition, I manually added:</p>
  
  <pre><code>appdirs==1.4.3
  </code></pre>
  
  <p>Next, I followed the instructions on an website instructing on how to disable collect static:</p>
  
  <pre><code>heroku config:set DISABLE_COLLECTSTATIC=1
  </code></pre>
  
  <p>This combination has gotten me a step further.</p>
  
  <p>Part 3
  All this done, I was now able to succesfully run the code:</p>
  
  <blockquote>
    <p>git push heroku master</p>
  </blockquote>
  
  <p>However, running:</p>
  
  <blockquote>
    <p>heroku ps</p>
  </blockquote>
  
  <p>directly afterwards, shows a crash</p>
  
  <blockquote>
    <p>web.1: crashed 2018/12/09 11:24:35 +0100 (~ 42m ago)</p>
  </blockquote>
  
  <p>trying to migrate the database using the below command:</p>
  
  <blockquote>
    <p>heroku run python manage.py migrate</p>
  </blockquote>
  
  <p>now let's me know, it is missing the module: dj-database-url</p>
  
  <blockquote>
    <p>ModuleNotFoundError: No module named 'dj_database_url'</p>
  </blockquote>
  
  <p>Looking at my requirements.txt file though, I clearly have this in the list here. </p>
  
  <p>Since the primary references in the net are either to check it is included in the requirements.txt file, the gunicorn file is defined correctly or collectstatic is disabled - I am at a loss and I hope someone might be able to help with this as well as hoping, the above pointers will benefit others dealing with the same early problems.</p>
  
  <p>My files look as follows:</p>
  
  <p>Procfile</p>
  
  <pre><code>web: gunicorn learning_log.wsgi —-log-file -
  </code></pre>
  
  <p>Procfile is with a capital "P" and the application is called learning_log</p>
  
  <p>requirements.txt</p>
  
  <pre><code>astroid==2.1.0
  autopep8==1.4.3
  dj-database-url==0.5.0
  dj-static==0.0.6
  Django==2.1.3
  gunicorn==19.9.0
  isort==4.3.4
  lazy-object-proxy==1.3.1
  mccabe==0.6.1
  pycodestyle==2.4.0
  pylint==2.2.2
  pytz==2018.7
  six==1.11.0
  static3==0.7.0
  wrapt==1.10.11
  django-bootstrap3==6.2.2
  psycopg2&gt;=2.6.1
  appdirs==1.4.3
  </code></pre>
  
  <p>wsgi.py</p>
  
  <pre><code>import os
  
  from django.core.wsgi import get_wsgi_application
  from whitenoise.django import DjangoWhiteNoise
  
  os.environ.setdefault("DJANGO_SETTINGS_MODULE", "learning_log.settings")
  application = get_wsgi_application()
  application = DjangoWhiteNoise(application)
  </code></pre>
  
  <p>snip from the settings.py-file:</p>
  
  <pre><code># Settings for django-bootstrap3
  BOOTSTRAP3 = {
      'include_jquery': True,
  }
  
  # Heroku Settings
  cwd = os.getcwd()
  print("--- CWD ---\n", cwd, "\n---\n")
  if cwd == '/app' or cwd[:4] == '/tmp':
      import dj_database_url
      DATABASES = {
          'default': dj_database_url.config(default='postgres://localhost')
      }
  
      # Honor the 'X-Forwarded-Proto' header for request.is_secure().
      SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
  
      # Allow all host headers.
      ALLOWED_HOSTS = ['*']
  
      # Static asset configuration
      BASE_DIR = os.path.dirname(os.path.abspath(__file__))
      STATIC_ROOT = 'staticfiles'
      STATICFILES_DIRS = (
          os.path.join(BASE_DIR, 'static'),
      )
  
      STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
  </code></pre>
  
  <p>runtime.txt</p>
  
  <blockquote>
    <p>python-3.7.0</p>
  </blockquote>
  
  <p>I sincerely hope, someone may be able to help here - I'm at a bit of a loss as to what else may be required.</p>
  
  <p>I hope this is sufficient to explain - I understand that apparently there were also some updates on Heroku's side, but to learn this is really difficult.</p>
  
  <p>Many thanks,
  Simon</p>