title: How to fix "relation does not exist"
body: <p>I am trying to run existing Django project, but always get the same error</p>
  
  <p>After running python manage.py I get error relation does not exist. I am using Django version 1.11.11. I think that there no need to be an error with database, because when I downgrade Django version to 1.8.1, there is no errors and migration is successful. What might be the problem?</p>
  
  <pre><code>Traceback (most recent call last):
    File "C:\Vizia_project\env\lib\site-packages\django\db\backends\utils.py", line 64, in execute
      return self.cursor.execute(sql, params)
  psycopg2.ProgrammingError: relation "qa_qagroup" does not exist
  LINE 1: SELECT (1) AS "a" FROM "qa_qagroup" LIMIT 1
                                 ^
  The above exception was the direct cause of the following exception:
  
  Traceback (most recent call last):
    File "manage.py", line 12, in &lt;module&gt;
      execute_from_command_line(sys.argv)
    File "C:\Vizia_project\env\lib\site-packages\django\core\management\__init__.py", line 364, in execute_from_command_line
      utility.execute()
    File "C:\Vizia_project\env\lib\site-packages\django\core\management\__init__.py", line 356, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
    File "C:\Vizia_project\env\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
      self.execute(*args, **cmd_options)
    File "C:\Vizia_project\env\lib\site-packages\django\core\management\base.py", line 327, in execute
      self.check()
    File "C:\Vizia_project\env\lib\site-packages\django\core\management\base.py", line 359, in check
      include_deployment_checks=include_deployment_checks,
    File "C:\Vizia_project\env\lib\site-packages\django\core\management\commands\migrate.py", line 62, in _run_checks
      issues.extend(super(Command, self)._run_checks(**kwargs))
    File "C:\Vizia_project\env\lib\site-packages\django\core\management\base.py", line 346, in _run_checks
      return checks.run_checks(**kwargs)
    File "C:\Vizia_project\env\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks
      new_errors = check(app_configs=app_configs)
    File "C:\Vizia_project\env\lib\site-packages\django\core\checks\urls.py", line 16, in check_url_config
      return check_resolver(resolver)
    File "C:\Vizia_project\env\lib\site-packages\django\core\checks\urls.py", line 26, in check_resolver
      return check_method()
    File "C:\Vizia_project\env\lib\site-packages\django\urls\resolvers.py", line 254, in check
      for pattern in self.url_patterns:
    File "C:\Vizia_project\env\lib\site-packages\django\utils\functional.py", line 35, in __get__
      res = instance.__dict__[self.name] = self.func(instance)
    File "C:\Vizia_project\env\lib\site-packages\django\urls\resolvers.py", line 405, in url_patterns
      patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
    File "C:\Vizia_project\env\lib\site-packages\django\utils\functional.py", line 35, in __get__
      res = instance.__dict__[self.name] = self.func(instance)
    File "C:\Vizia_project\env\lib\site-packages\django\urls\resolvers.py", line 398, in urlconf_module
      return import_module(self.urlconf_name)
    File "C:\Vizia_project\env\lib\importlib\__init__.py", line 104, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "&lt;frozen importlib._bootstrap&gt;", line 2231, in _gcd_import
    File "&lt;frozen importlib._bootstrap&gt;", line 2214, in _find_and_load
    File "&lt;frozen importlib._bootstrap&gt;", line 2203, in _find_and_load_unlocked
    File "&lt;frozen importlib._bootstrap&gt;", line 1200, in _load_unlocked
    File "&lt;frozen importlib._bootstrap&gt;", line 1129, in _exec
    File "&lt;frozen importlib._bootstrap&gt;", line 1448, in exec_module
    File "&lt;frozen importlib._bootstrap&gt;", line 321, in _call_with_frames_removed
    File "C:\Vizia_project\banknote\urls.py", line 24, in &lt;module&gt;
      from qa.views import *
    File "C:\Vizia_project\qa\views.py", line 11, in &lt;module&gt;
      class QAGroupFilter(django_filters.FilterSet):
    File "C:\Vizia_project\qa\views.py", line 13, in QAGroupFilter
      if QAGroup.objects.exists():
    File "C:\Vizia_project\env\lib\site-packages\django\db\models\manager.py", line 85, in manager_method
      return getattr(self.get_queryset(), name)(*args, **kwargs)
    File "C:\Vizia_project\env\lib\site-packages\django\db\models\query.py", line 670, in exists
      return self.query.has_results(using=self.db)
    File "C:\Vizia_project\env\lib\site-packages\django\db\models\sql\query.py", line 517, in has_results
      return compiler.has_results()
    File "C:\Vizia_project\env\lib\site-packages\django\db\models\sql\compiler.py", line 858, in has_results
      return bool(self.execute_sql(SINGLE))
    File "C:\Vizia_project\env\lib\site-packages\django\db\models\sql\compiler.py", line 899, in execute_sql
      raise original_exception
    File "C:\Vizia_project\env\lib\site-packages\django\db\models\sql\compiler.py", line 889, in execute_sql
      cursor.execute(sql, params)
    File "C:\Vizia_project\env\lib\site-packages\django\db\backends\utils.py", line 79, in execute
      return super(CursorDebugWrapper, self).execute(sql, params)
    File "C:\Vizia_project\env\lib\site-packages\django\db\backends\utils.py", line 64, in execute
      return self.cursor.execute(sql, params)
    File "C:\Vizia_project\env\lib\site-packages\django\db\utils.py", line 94, in __exit__
      six.reraise(dj_exc_type, dj_exc_value, traceback)
    File "C:\Vizia_project\env\lib\site-packages\django\utils\six.py", line 685, in reraise
      raise value.with_traceback(tb)
    File "C:\Vizia_project\env\lib\site-packages\django\db\backends\utils.py", line 64, in execute
      return self.cursor.execute(sql, params)
  django.db.utils.ProgrammingError: relation "qa_qagroup" does not exist
  LINE 1: SELECT (1) AS "a" FROM "qa_qagroup" LIMIT 1
                                 ^
  
  requirements.txt looks this:
  beautifulsoup4==4.6.0
  certifi==2017.7.27.1
  chardet==3.0.4
  Django==1.11.11
  django-crispy-forms==1.7.1
  django-filter==1.1.0
  django-modelcluster==3.1
  django-session-security==2.6.0
  django-taggit==0.22.1
  django-treebeard==4.1.2
  djangorestframework==3.6.4
  html5lib==0.999999999
  idna==2.6
  olefile==0.44
  Pillow==4.3.0
  psycopg2==2.7.3.2
  python-dateutil==2.6.1
  pytz==2017.2
  raven==6.3.0
  requests==2.18.4
  six==1.11.0
  Unidecode==0.4.21
  urllib3==1.22
  wagtail==1.12.2
  webencodings==0.5.1
  wheel==0.24.0
  Willow==0.4
  </code></pre>
  
  <p>views.py from qa</p>
  
  <pre><code>from django.shortcuts import render
  import django_filters
  from qa.models import QAGroup
  from qa.forms import QAForm
  from django.shortcuts import redirect
  from django.utils.translation import ugettext_lazy as _
  from django.contrib import messages
  
  # Create your views here.
  
  class QAGroupFilter(django_filters.FilterSet):
  
      if QAGroup.objects.exists():
          initial = QAGroup.objects.first().pk
      else:
          initial = None
  
      group = django_filters.ModelChoiceFilter(
          queryset=QAGroup.objects.order_by('pk'),
          # widget=LinkWidget(),
          label='',
          empty_label=None,
          name='title',
          initial=initial,
      )
  
  
      def __init__(self, data=None, *args, **kwargs):
          # filterset is bound, use initial values as defaults
          if data is not None:
              data = data.copy()
  
              for name, f in self.base_filters.items():
                  initial = f.extra.get('initial')
  
                  # filter param is either missing or empty, use initial as default
                  if not data.get(name) and initial:
                      data[name] = initial
  
          super(QAGroupFilter, self).__init__(data, *args, **kwargs)
  
      class Meta:
          model = QAGroup
          fields = ['group', ]
  
  
  def qa_list(request):
      filter = QAGroupFilter(request.GET, queryset=QAGroup.objects.all())
      groups = QAGroup.objects.order_by('pk')
      form = QAForm()
  
      if request.method == 'POST':
          form = QAForm(request.POST)
          if form.is_valid():
              form.send_email()
              messages.add_message(request, messages.INFO, _('Some text here'))
              return redirect('faq')
  
      return render(request, 'qa/qa.html', {'filter': filter, 'groups': groups, 'form': form})
  </code></pre>