gpt4 book ai didi

python - 当我运行测试用例时,出现此错误 : psycopg2. OperationalError: cursor "_django_curs_140351416325888_23"does not exist

转载 作者:太空狗 更新时间:2023-10-29 19:33:31 26 4
gpt4 key购买 nike

我正在尝试运行测试用例,但出现以下错误。

运行命令:python manage.py test

Type 'yes' if you would like to try deleting the test database 'test_project_management_db', or 'no' to cancel: yes
Destroying old test database for alias 'default'...

Traceback (most recent call last):
File "manage.py", line 24, in <module>
execute_from_command_line(sys.argv)
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 29, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 62, in handle
failures = test_runner.run_tests(test_labels)
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/test/runner.py", line 601, in run_tests
old_config = self.setup_databases()
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/test/runner.py", line 546, in setup_databases
self.parallel, **kwargs
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/test/utils.py", line 187, in setup_databases
serialize=connection.settings_dict.get('TEST', {}).get('SERIALIZE', True),
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/db/backends/base/creation.py", line 77, in create_test_db
self.connection._test_serialized_contents = self.serialize_db_to_string()
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/db/backends/base/creation.py", line 121, in serialize_db_to_string
serializers.serialize("json", get_objects(), indent=None, stream=out)
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/core/serializers/__init__.py", line 129, in serialize
s.serialize(queryset, **options)
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/core/serializers/base.py", line 80, in serialize
for count, obj in enumerate(queryset, start=1):
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/db/backends/base/creation.py", line 117, in get_objects
for obj in queryset.iterator():
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/db/models/query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
File "/home/rails/Desktop/projects/envs/project_manage_env/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 880, in execute_sql
cursor.close()
psycopg2.OperationalError: cursor "_django_curs_140351416325888_23" does not exist

最佳答案

当我遇到这个问题时,原来是因为我在模型中添加了字段,而忘记了makemigrationsmigrate

在这种情况下,通常您会收到来自 Django 的警告,但由于某种原因我没有收到。

关于python - 当我运行测试用例时,出现此错误 : psycopg2. OperationalError: cursor "_django_curs_140351416325888_23"does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48184300/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com