После череды глупых ошибок, которые заставили меня напрямую импортировать данные в PostgreS БД, а затем удалить базу данных после того, как это вызвало дублирующиеся ключевые проблемы, я получаю сообщение об ошибке (полная трассировка ниже) на makemigrations / migrate / runserver.
Я вернулся к SQLite, и он работает нормально, однако мне нужно запустить его в PG. Я восстановил базу данных, поэтому структура таблицы верна, однако я все еще получаю ту же ошибку, поэтому я предполагаю (предполагаю), что на стороне Django / Python есть кешированный код sql, который вызывает сбой .
Обратите внимание, что lead_auditor_id нигде в моем проекте не упоминается, хотя есть таблица lead_auditor, в которой есть столбец id по умолчанию.
Любые подсказки были бы очень кстати после многих часов, потраченных на поиск и опробование различных решений.
$ py manage.py makemigrations
Traceback (most recent call last):
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedColumn: column actionlog_action.lead_auditor_id does not exist
LINE 1: ..."."action", "actionlog_action"."action_owner_id", "actionlog...
^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 366, in execute
self.check()
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 392, in check
all_issues = self._run_checks(
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 382, in _run_checks
return checks.run_checks(**kwargs)
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 407, in check
for pattern in self.url_patterns:
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 588, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 581, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Jon\django_projects\effortlessactiontracker\effortlessactiontracker\urls.py", line 24, in <module>
path('actionlog/', include('actionlog.urls')),
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Jon\django_projects\effortlessactiontracker\actionlog\urls.py", line 4, in <module>
from . import views
File "C:\Users\Jon\django_projects\effortlessactiontracker\actionlog\views.py", line 99, in <module>
class OverdueActionListView(LoginRequiredMixin, generic.ListView):
File "C:\Users\Jon\django_projects\effortlessactiontracker\actionlog\views.py", line 102, in OverdueActionListView
num_actions_overdue = len(list(filter(lambda action: action.overdue, Action.objects.all())))
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 276, in __iter__
self._fetch_all()
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 1261, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\query.py", line 57, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\models\sql\compiler.py", line 1151, in execute_sql
cursor.execute(sql, params)
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 100, in execute
return super().execute(sql, params)
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\Jon\AppData\Local\Programs\Python\Python38\lib\site-packages\django\db\backends\utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column actionlog_action.lead_auditor_id does not exist
LINE 1: ..."."action", "actionlog_action"."action_owner_id", "actionlog...