title: "Error while running '$ python manage.py collectstatic --noinput'" after changing database on django
body: <p>I'm a bit of a beginner with Django so forgive me if I'm missing some necessary information. I recently revised my database on settings.py and I keep getting an error when I run</p>
  
  <pre><code>    git push heroku master
  </code></pre>
  
  <p>The error block looks like: </p>
  
  <pre><code>    Counting objects: 22, done.
  Delta compression using up to 8 threads.
  Compressing objects: 100% (22/22), done.
  Writing objects: 100% (22/22), 4.84 KiB | 825.00 KiB/s, done.
  Total 22 (delta 12), reused 0 (delta 0)
  remote: Compressing source files... done.
  remote: Building source:
  remote: 
  remote: -----&gt; Python app detected
  remote:  !     Python has released a security update! Please consider upgrading to python-3.6.8
  remote:        Learn More: https://devcenter.heroku.com/articles/python-runtimes
  remote: -----&gt; Installing requirements with pip
  remote: 
  remote: -----&gt; $ python manage.py collectstatic --noinput
  remote:        Traceback (most recent call last):
  remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/postgresql/base.py", line 20, in &lt;module&gt;
  remote:            import psycopg2 as Database
  remote:        ModuleNotFoundError: No module named 'psycopg2'
  remote:        During handling of the above exception, another exception occurred:
  remote:        Traceback (most recent call last):
  remote:          File "manage.py", line 15, in &lt;module&gt;
  remote:            execute_from_command_line(sys.argv   )
  remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line  
  remote:            utility.execute()
  remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
  remote:            django.setup()
  remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
  remote:            apps.populate(settings.INSTALLED_APPS)
  remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 112, in populate
  remote:            app_config.import_models()
  remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 198, in import_models
  remote:            self.models_module = import_module(models_module_name)
  remote:          File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
  remote:            return _bootstrap._gcd_import(name[level:], package, level)
  remote:          File "&lt;frozen importlib._bootstrap&gt;", line 994, in _gcd_import
  remote:          File "&lt;frozen importlib._bootstrap&gt;", line 971, in _find_and_load
  remote:          File "&lt;frozen importlib._bootstrap&gt;", line 955, in _find_and_load_unlocked
  remote:          File "&lt;frozen importlib._bootstrap&gt;", line 665, in _load_unlocked
  remote:          File "&lt;frozen importlib._bootstrap_external&gt;", line 678, in exec_module
  remote:          File "&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed
  remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/auth/models.py", line 2, in &lt;module&gt;
  remote:            from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 47, in &lt;module&gt;
  remote:            class AbstractBaseUser(models.Model):
  remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/base.py", line 101, in __new__
  remote:            new_class.add_to_class('_meta', Options(meta, app_label))
  remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/base.py", line 305, in add_to_class
  remote:            value.contribute_to_class(cls, name)
  remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/options.py", line 203, in contribute_to_class
  remote:            self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/db/__init__.py", line 33, in __getattr__
  remote:            return getattr(connections[DEFAULT_DB_ALIAS], item)
  remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 202, in __getitem__
  remote:            backend = load_backend(db['ENGINE'])
  remote:          File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 110, in load_backend
  remote:            return import_module('%s.base' % backend_name)
  remote:          File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
  remote:             return _bootstrap._gcd_import(name[level:], package, level)
  remote:           File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/postgresql/  base.py", line 24, in &lt;module&gt;
  remote:            raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
  remote:        django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: No module    named 'psycopg2'
  remote: 
  remote:  !     Error while running '$ python manage.py collectstatic --noinput'.
  remote:        See traceback above for details.
  remote: 
  remote:        You may need to update application code to resolve this error.
  remote:        Or, you can disable collectstatic for this application:
  remote: 
  remote:           $ heroku config:set DISABLE_COLLECTSTATIC=1
  remote: 
  remote:        https://devcenter.heroku.com/articles/django-assets
  remote:  !     Push rejected, failed to compile Python app.
  remote: 
  remote:  !     Push failed
  remote: Verifying deploy...
  remote: 
  remote: !   Push rejected to ewbunlv.
  remote: 
  To https://git.heroku.com/ewbunlv.git
   ! [remote rejected] master -&gt; master (pre-receive hook declined)
  error: failed to push some refs to 'https://git.heroku.com/ewbunlv.git'
  </code></pre>
  
  <p>This is the part of my settings.py that I changed (originally the default database Django has)</p>
  
  <pre><code>    # Database
      # https://docs.djangoproject.com/en/2.1/ref/settings/#databases
  
      DATABASES = {
          'default': {
              'ENGINE': 'django.db.backends.postgresql_psycopg2', #Used 'django.db.backends.postgresql' as well
              'NAME': 'myname',
              USER': 'user',
              'PASSWORD': 'password',
              'HOST': 'host',
              'PORT': '5432',
          }
      }
  </code></pre>
  
  <p>my requirements.txt:</p>
  
  <pre><code>    awscli==1.16.91
  boto==2.49.0
  boto3==1.9.81
  botocore==1.12.81
  certifi==2018.11.29
  chardet==3.0.4
  colorama==0.3.9
  dj-database-url==0.5.0
  Django==2.1.4
  django-cleanup==3.0.1
  django-s3-folder-storage==0.5
  django-storages==1.7.1
  docutils==0.14
  gunicorn==19.9.0
  heroku==0.1.4
  idna==2.8
  jmespath==0.9.3
  Pillow==5.3.0
  pyasn1==0.4.5
  python-dateutil==2.7.5
  pytz==2018.7
  PyYAML==3.13
  requests==2.21.0
  rsa==3.4.2
  s3transfer==0.1.13
  six==1.12.0
  urllib3==1.24.1
  whitenoise==4.1.2
  </code></pre>
  
  <p>I've run </p>
  
  <pre><code>    heroku run python manage.py collectstatic --dry-run --noinput
  </code></pre>
  
  <p>and it works perfectly fine, no errors whatsoever. I've been working on this for a while now to no avail. </p>
  
  <p>It works fine locally as well, but when I try to translate it to production, I get the error mentioned above. What am I missing?</p>