django-evolution 错误

发布于 2024-11-24 21:07:43 字数 1319 浏览 0 评论 0原文

我正在尝试使用 django-evolution 修改现有项目中的一些模型。现在,当我使用syncdb时,它说我需要进行“进化”。

当我尝试运行时:

python manage.py evolve --hint --execute

我在终端中显示此错误,但我对此仍然陌生,因此我无法解决此错误。

错误代码:

Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/home/steve/lib/python2.6/site-packages/django/core/management/__init__.py", line 361, in execute_manager
utility.execute()
File "/home/steve/lib/python2.6/site-packages/django/core/management/__init__.py", line 306, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/steve/lib/python2.6/site-packages/django/core/management/base.py", line 192, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/steve/lib/python2.6/site-packages/django/core/management/base.py", line 219, in execute
output = self.handle(*args, **options)
File "/var/sites/placeholder/placeholder/placeholder/apps/django_evolution/management/commands/evolve.py", line 87, in handle
hinted_evolution = diff.evolution()
File "/var/sites/placeholder/placeholder/placeholder/apps/django_evolution/diff.py", line 197, in evolution
changed_attrs[prop] = current_field_sig.get(prop, ATTRIBUTE_DEFAULTS[prop])
KeyError: 'field_type'

谢谢,希望有人能帮助我。

史蒂夫

I'm trying to use django-evolution to modify some models from an existing project. Now when I go a syncdb it says that I need to do a 'evolve'.

When I try to run:

python manage.py evolve --hint --execute

I am shown this error in the terminal, but I am still new to this so I am having trouble troubleshooting this error.

Error code:

Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/home/steve/lib/python2.6/site-packages/django/core/management/__init__.py", line 361, in execute_manager
utility.execute()
File "/home/steve/lib/python2.6/site-packages/django/core/management/__init__.py", line 306, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/steve/lib/python2.6/site-packages/django/core/management/base.py", line 192, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/steve/lib/python2.6/site-packages/django/core/management/base.py", line 219, in execute
output = self.handle(*args, **options)
File "/var/sites/placeholder/placeholder/placeholder/apps/django_evolution/management/commands/evolve.py", line 87, in handle
hinted_evolution = diff.evolution()
File "/var/sites/placeholder/placeholder/placeholder/apps/django_evolution/diff.py", line 197, in evolution
changed_attrs[prop] = current_field_sig.get(prop, ATTRIBUTE_DEFAULTS[prop])
KeyError: 'field_type'

Thanks, and hopefully someone can help me out.

Steve

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

双手揣兜 2024-12-01 21:07:43

我已经解决了这个问题,我会为遇到同样问题的人发帖。

我意识到我正处于项目的一个非常稳定的部分。因此,我对数据库进行了备份,然后删除了 django_evolution 使用的 2 个表。

然后我运行syncdb 再次创建表。

这似乎有效,我能够进行我的进化。

I have solved it, and I will post for anyone coming across the same issue.

I realized that I was at a very stable part of my project. So I made a backup of my db and went ahead and dropped the 2 tables that django_evolution works with.

Then I ran a syncdb to create the tables again.

This seemed to have worked and I was able to do my evolutions.

琴流音 2024-12-01 21:07:43

我将详细阐述史蒂夫的回答。

要查看 django_evolution 在项目数据库中创建的两个表,请使用以下命令:

python manage.py sql django_evolution

实际上并不需要上述命令。您可以立即移除表格或重置表格。请注意,要使上述命令起作用,您需要在 INSTALLED_APPS 中安装名为“django_evolution”的应用程序。我将提供一个在 Django1.2.7 上对我有用的命令。是的,我仍然使用1.2.7版本,因为到目前为止我没有理由升级。我的答案末尾提供了解决此问题的各种方法。您可以使用以下命令进行重置:

python manage.py reset django_evolution

输入“yes”接受重置查询。

现在执行数据库同步:

python manage.py syncdb

该命令将告诉您需要发展。键入以下命令以进行演化:

python manage.py evolve --hint

如果您对上述命令提供的提示感到满意,请继续执行演化:

python manage.py evolve --hint --execute

键入“yes”确认执行。

所有旧表和关联数据都将无缝运行。要检查类型:

python manage.py runserver

如何从 SQLite3 中删除表在 DJango 中?

I will elaborate on Steve's answer.

To view the two tables that django_evolution creates within your project database use the command:

python manage.py sql django_evolution

The above command is not really needed. You can straightaway go to removing the tables or reseting the tables. Note that for the above command to work, you will need the app called 'django_evolution' in your INSTALLED_APPS. I will provide one command that worked for me on Django1.2.7. Yes, I am still on version 1.2.7, because so far I did not have reason to upgrade. Various ways of solving this problem is provided at the end of my answer. You use the following command to reset:

python manage.py reset django_evolution

Accept the resetting query by typing 'yes'.

Now perform database synchronization with:

python manage.py syncdb

This command will tell you that you need to evolve. Type the following command for evolution to happen:

python manage.py evolve --hint

If you are ok with the hint provided by above command, go ahead and execute the evolution:

python manage.py evolve --hint --execute

Confirm the execution by typing 'yes'.

All your old tables and associated data will work seamlessly. To check type:

python manage.py runserver

How do I drop a table from SQLite3 in DJango?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文