@IrinaTravel

Почему возникает ошибка при миграции БД в Django 1.11.2 после клонирования с Github?

Привет всем!

Подскажите, пожалуйста, в чём может быть проблема. Ситуация такая: есть проект в приватном репозитории GitHub на Django 1.11.2 (не пустой, в активной разработке). Делаю git clone для него (заливаю с нуля), открываю в PyCharm и ввожу в консоли python manage.py migrate.

На компе (Win8.1 x64) установлен PostgreSQL 9.6.x, создан пользователь/таблица, в проекте (settings.py) всё прописано, тестовое соединение в настройках PyCharm — success.


Вижу вот эту ошибку:

$ 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...
                                                             ^


Также неясно, почему не делается первоначальная инициализация БД (где auth/sessions/etc таблицы создаются)? Как вообще нужно организовывать работу с git для Django проекта? Что гитигнорить, а что наоборот оставлять?

Буду рада любой помощи...
  • Вопрос задан
  • 1152 просмотра
Решения вопроса 1
@immaculate
Программист-путешественник
Ошибка в миграциях где-то. Ответить на вопрос из озвученных исходных данных невозможно. Можно только видя весь код и базу, используя команды showmigrations, migrate --fake-initial, migrate, migrate --fake попытаться решить ситуацию.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы