Django模型中的新字段未以管理界面或模型形式显示 [英] New field in Django model doesn't show up in admin interface or model forms

查看:59
本文介绍了Django模型中的新字段未以管理界面或模型形式显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在一个应用程序中创建了一个可以正常运行的模型。但是,我需要添加一个新字段。我这样做了,并使用 manage.py reset< appname> 删除表并再次添加它们。这个过程进行得很好-新字段出现在数据库中。但是,我无法在管理界面或我创建的自定义模型表单中显示该字段。因为我没有给它一个默认值(并且不想,也不需要),所以我无法使用这两种方法在数据库中添加一行。有什么想法吗?

I've created a model in one of my apps which works fine. However, I needed to add a new field. I did this, and used manage.py reset <appname> to drop the tables and add them again. This process went fine - the new field appears in the database. However, I can't get the field to show up in the admin interface, nor in the custom model form I've created. Because I haven't given it a default value (and don't want to, nor should I need to) I can't use either method to add a row into the database. Any ideas?

模型片段:

use_balance = models.BooleanField()


推荐答案

您是否重新启动了服务器?

Have you restarted your server?

这篇关于Django模型中的新字段未以管理界面或模型形式显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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