如何从SQLite3在DJango中删除表? [英] How do I drop a table from SQLite3 in DJango?

查看:155
本文介绍了如何从SQLite3在DJango中删除表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个模型,并运行python manage.py syncdb。我认为在db中创建了一个表。然后我意识到我做了一个不正确的列,所以我改变它,并执行相同的命令,认为它会删除旧的表,并添加一个新的。

I made a model, and ran python manage.py syncdb. I think that created a table in the db. Then I realized that I had made a column incorrectly, so I changed it, and ran the same command, thinking that it would drop the old table, and add a new one.

然后我去了python manage.py shell,并试图运行.objects.all(),它失败,说列不存在。

Then I went to python manage.py shell, and tried to run .objects.all(), and it failed, saying that column doesn't exist.

我想清除旧的表,然后再次运行syncdb,但我不知道该怎么做。

I want to clear out the old table, and then run syncdb again, but I can't figure out how to do that.

推荐答案

p>另一种使用Django 1.4或更低版本的简单方法是

Another simple way to do this while using Django 1.4 or below, would be

python manage.py reset app_name

会删除并重新创建此应用程序的模型所使用的表。

which drops and re-creates the tables used by the models of this app.

这已在Django 1.3中弃用,不再可从Django 1.5中使用

This was deprecated in Django 1.3 and is no longer available from Django 1.5

这篇关于如何从SQLite3在DJango中删除表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆