开发者

django-evolution error

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 = s开发者_开发知识库elf.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


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.


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜