I have an application in Django 1.6.5. I have a model where I removed one field, I added another field, and the third upgraded. And when we now turn to the model in the admin panel, I get the message:
我有一个Django 1.6.5的应用程序。我有一个模型,我删除了一个字段,添加了另一个字段,第三个字段升级了。当我们现在转向管理面板中的模型时,我得到了一个信息:
ProgrammingError at /admin/app/subscription/column app_subscription.enabled does not existThe command python manage.py syncdb does not work.
python命令管理。py syncdb不起作用。
2 个解决方案
#1
2
Django (hopefully) doesn't modify your database schema if you don't explicitely ask for it. The syncdb command works perfectly, but (as documented) it will only create tables that don't yet exists (and are not marked as being managed externally in your models).
如果您不明确地要求的话,Django(希望如此)不会修改您的数据库模式。syncdb命令工作得很好,但是(如文档所示)它只创建尚未存在的表(并且在模型中没有被标记为外部管理)。
So you have mostly three options here:
所以你有三个选择:
Note that solution #3 imply that you do create the migration files for your app, as documented here : http://south.readthedocs.org/en/latest/tutorial/part1.html#the-first-migration
请注意解决方案#3暗示您确实为您的应用创建了迁移文件,如本文所述:http://south.readthedocs.org/en/latest/tutorial/part1.html#the first-migration
#2
0
It just happened that I faced the same issue with django 1.9.x, where I added a new field in my django app which triggered the same error as you mentioned above. I logged into the dbshell environment using
碰巧我在django 1.9中遇到了同样的问题。我在django应用程序中添加了一个新字段,它触发了您上面提到的错误。我使用dbshell环境登录
python manage.p dbshell # I know some use ./manage.pyand dropped all of my tables by running the following command within the dbshell to drop the tables
并通过在dbshell中运行以下命令删除所有表
your_psql=# drop schema public cascade;This will drop all of your tables (be careful as you may lose your data, there away to keep the data!) and you will get a message right after executing this command tells you that all dropped. Right after that run the following command to create the schema again, otherwise your server will not run:
这将删除所有的表(注意,您可能会丢失数据,将数据保存在那里!)运行以下命令再次创建模式,否则您的服务器将不会运行:
your_psql=# create schema public;Then just do the
然后就做
python manage.py makemigrations # you might not need this, and python manage.py migrateAnd you're ready to go.
你准备好了。
I know this answer might be very late but I hope it will help someone.
我知道这个答案可能会很晚,但我希望它能帮助某人。
Cheers
干杯