I
I
Irina Travel2017-06-22 13:22:29
Django
Irina Travel, 2017-06-22 13:22:29

Why does an error occur when migrating a database to Django 1.11.2 after cloning from Github?

Hi all!
Tell me, please, what could be the problem. The situation is this: there is a project in a private GitHub repository on Django 1.11.2 (not empty, in active development). I do git cloneit for him (upload from scratch), open it in PyCharm and enter in the console python manage.py migrate.

PostgreSQL 9.6.x is installed on the computer (Win8.1 x64), the user/table is created, settings.pyeverything is written in the project ( ), the test connection in the PyCharm settings is success.

I see this error:
$ python manage.py migrate

Traceback (most recent call last):
  File "...\Programs\Python\Python36-32\lib\site-packages\django\db\backends\utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: ОШИБКА:  отношение "citizenship_citizenship" не существует
LINE 1: ...enship_citizenship"."is_available_for_order" FROM "citizensh...
                                                             ^
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "...\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "...\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 355, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "...\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "...\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 327, in execute
    self.check()
  File "...\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 359, in check
    include_deployment_checks=include_deployment_checks,
  File "...\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\migrate.py", line 62, in _run_checks
    issues.extend(super(Command, self)._run_checks(**kwargs))
  File "...\Programs\Python\Python36-32\lib\site-packages\django\core\management\base.py", line 346, in _run_checks
    return checks.run_checks(**kwargs)
  File "...\Programs\Python\Python36-32\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "...\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py", line 16, in check_url_config
    return check_resolver(resolver)
  File "...\Programs\Python\Python36-32\lib\site-packages\django\core\checks\urls.py", line 26, in check_resolver
    return check_method()
  File "...\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 254, in check
    for pattern in self.url_patterns:
  File "...\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "...\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 405, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "...\Programs\Python\Python36-32\lib\site-packages\django\utils\functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "...\Programs\Python\Python36-32\lib\site-packages\django\urls\resolvers.py", line 398, in urlconf_module
    return import_module(self.urlconf_name)
  File "...\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "...\django_trt\django_trt\urls.py", line 10, in <module>
    url(r'^account/', include('clients.urls')),
  File "...\Programs\Python\Python36-32\lib\site-packages\django\conf\urls\__init__.py", line 50, in include
    urlconf_module = import_module(urlconf_module)
  File "...\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "...\django_trt\clients\urls.py", line 6, in <module>
    from .views import *
  File "...\django_trt\clients\views.py", line 9, in <module>
    from .forms import ClientChangeForm
  File "...\django_trt\clients\forms.py", line 73, in <module>
    class ClientChangeForm(forms.ModelForm):
  File "...\django_trt\clients\forms.py", line 74, in ClientChangeForm
    class Meta:
  File "...\django_trt\clients\forms.py", line 149, in Meta
    'class': 'citizenship-select',
  File "...\Programs\Python\Python36-32\lib\site-packages\django\forms\widgets.py", line 544, in __init__
    self.choices = list(choices)
  File "...\Programs\Python\Python36-32\lib\site-packages\django\db\models\query.py", line 250, in __iter__
    self._fetch_all()
  File "...\Programs\Python\Python36-32\lib\site-packages\django\db\models\query.py", line 1105, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "...\Programs\Python\Python36-32\lib\site-packages\django\db\models\query.py", line 53, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
  File "...\Programs\Python\Python36-32\lib\site-packages\django\db\models\sql\compiler.py", line 886, in execute_sql
    raise original_exception
  File "...\Programs\Python\Python36-32\lib\site-packages\django\db\models\sql\compiler.py", line 876, in execute_sql
    cursor.execute(sql, params)
  File "...\Programs\Python\Python36-32\lib\site-packages\django\db\backends\utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "...\Programs\Python\Python36-32\lib\site-packages\django\db\utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "...\Programs\Python\Python36-32\lib\site-packages\django\utils\six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "...\Programs\Python\Python36-32\lib\site-packages\django\db\backends\utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: ОШИБКА:  отношение "citizenship_citizenship" не существует
LINE 1: ...enship_citizenship"."is_available_for_order" FROM "citizensh...
                                                             ^

It's also not clear why the initial DB initialization is not done (where the auth/sessions/etc tables are created)? How do you generally organize work with git for a Django project? What to ignore, and what to leave on the contrary?
I would appreciate any help...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2017-06-22
@IrinaTravel

There is a bug in the migrations somewhere. It is impossible to answer the question from the voiced initial data. You can only see the whole code and base, using the showmigrations, migrate --fake-initial, migrate, migrate --fake commands to try to solve the situation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question