title: Python Django - Internal Error ProgrammingError relation does not exist
body: <p>This might probably be a duplicated question, but I can't find a post to answer my questions yet. Any post that is similar to this may help is appreciated.</p>
  <p>I tried to host my Django app using heroku.com</p>
  <pre><code>git add .
  git commit -m &quot;(commit_name)&quot;
  git push heroku master
  </code></pre>
  <p>When I tried to test the website (<code>/questions/1</code>), the website shows an Error 500 (Internal Error).
  First it shows a ProgrammingError: relation does not exist.
  After that I did <code>$ heroku run python manage.py migrate</code> try to solve the problem. The original error disappeared, but instead this happened:</p>
  <pre><code>2020-08-29T11:05:42.668070+00:00 app[web.1]: Internal Server Error: /questions/1
  2020-08-29T11:05:42.668070+00:00 app[web.1]:
  2020-08-29T11:05:42.668070+00:00 app[web.1]: DoesNotExist at /questions/1
  2020-08-29T11:05:42.668071+00:00 app[web.1]: Question matching query does not exist.
  </code></pre>
  <p><code>Settings.py</code>:</p>
  <pre class="lang-py prettyprint-override"><code>import django_heroku
  
  from pathlib import Path
  
  import os
  
  #--------------------(ommited)--------------------#
  
  # SECURITY WARNING: don't run with debug turned on in production!
  DEBUG = False
  
  ALLOWED_HOSTS = ['*']
  
  
  # Application definition
  
  INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'myapp',
  ]
  
  MIDDLEWARE = [
      'django.middleware.security.SecurityMiddleware',
      'django.contrib.sessions.middleware.SessionMiddleware',
      'django.middleware.common.CommonMiddleware',
      'django.middleware.csrf.CsrfViewMiddleware',
      'django.contrib.auth.middleware.AuthenticationMiddleware',
      'django.contrib.messages.middleware.MessageMiddleware',
      'django.middleware.clickjacking.XFrameOptionsMiddleware',
  ]
  
  ROOT_URLCONF = 'myweb.urls'
  
  TEMPLATES = [
      {
          'BACKEND': 'django.template.backends.django.DjangoTemplates',
          'DIRS': [os.path.join(BASE_DIR, 'templates'),],
          'APP_DIRS': True,
          'OPTIONS': {
              'context_processors': [
                  'django.template.context_processors.debug',
                  'django.template.context_processors.request',
                  'django.contrib.auth.context_processors.auth',
                  'django.contrib.messages.context_processors.messages',
              ],
          },
      },
  ]
  
  WSGI_APPLICATION = 'myweb.wsgi.application'
  
  
  # Database
  # https://docs.djangoproject.com/en/3.1/ref/settings/#databases
  
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.sqlite3',
          'NAME': BASE_DIR / 'db.sqlite3',
      }
  }
  
  
  # Password validation
  # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators
  
  AUTH_PASSWORD_VALIDATORS = [
      {
          'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
      },
  ]
  
  
  # Internationalization
  # https://docs.djangoproject.com/en/3.1/topics/i18n/
  
  LANGUAGE_CODE = 'zh-Hant'
  
  TIME_ZONE = 'Asia/Taipei'
  
  USE_I18N = True
  
  USE_L10N = True
  
  USE_TZ = True
  
  
  # Static files (CSS, JavaScript, Images)
  # https://docs.djangoproject.com/en/3.1/howto/static-files/
  
  STATIC_URL = '/static/'
  STATICFILES_DIRS = [
      os.path.join(BASE_DIR, 'static'),
  ]
  
  STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
  
  STATIC_ROOT = os.path.join(BASE_DIR, 'static')
  
  # Activate Django-Heroku.
  django_heroku.settings(locals())
  </code></pre>
  <p><code>Models.py</code>:</p>
  <pre class="lang-py prettyprint-override"><code>from django.db import models
  from django.utils import timezone
  import json
  
  # Create your models here.
  
  class Code(models.Model):
      code = models.TextField()
      number = models.IntegerField()
  
  class Question(models.Model):
      title = models.TextField()
      text = models.TextField()
      judges = models.TextField()
      number = models.IntegerField()
  
      class Meta:
          ordering = ['number']
  
      def set_judges(self, x):
          self.judges = json.dumps(x)
  
      def get_judges(self):
          return json.loads(self.judges)
  </code></pre>
  <p><code>wsgi.py</code>:</p>
  <pre class="lang-py prettyprint-override"><code>import os
  
  from dj_static import Cling
  from django.core.wsgi import get_wsgi_application
  
  os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myweb.settings')
  
  application = Cling(get_wsgi_application())
  </code></pre>
  <p>Any suggestions or things I should try? Thank you.</p>
  <p>[EDIT]: It seems that the database is empty now so it cause the error. But when I run the same file in my computer as I git push to heroku, the database isn't empty and it works fine.</p>