我正在创建自己的Group
模型;我不是指内置的Group
模型。我希望每个hroup都是另一个组(它是父组)的成员,但是有一个“top”组没有父组。在
管理界面不允许我在没有输入父级的情况下创建组。我得到错误personnel_group.parent_id may not be NULL
。我的Group
模型如下所示:
class Group(models.Model):
name = models.CharField(max_length=50)
parent = models.ForeignKey('self', blank=True, null=True)
order = models.IntegerField()
icon = models.ImageField(upload_to='groups', blank=True, null=True)
description = models.TextField(blank=True, null=True)
我怎样才能做到这一点?在
谢谢。在
Django evolution可以在不丢失完整数据库的情况下解决此类问题
在将
blank=True, null=True
添加到parent
字段定义之前,我创建了数据库。syncdb无法处理这种类型的更改,因此Django没有接受我的更改。在我删除了我的数据库,让syncdb创建另一个,它工作得很好。在
相关问题 更多 >
编程相关推荐