class Project(models.Model):
"""项目的model定义"""
REL_CHOICES=(('是','已发布'),('否','未发布'),)
proid = models.CharField("项目编号",max_length = 20,primary_key = True)
proname = models.CharField("项目名称",max_length = 25)
prostarttime = models.DateField("项目开始时间")
prorelease = models.CharField("是否已发布",max_length = 5,choices = REL_CHOICES)
proreltime = models.DateField("项目发布时间")
proparticipants = models.ManyToManyField(User)#参与人员
proplantime = models.IntegerField("计划周期:天")
prodataids = models.ManyToManyField(Data,blank=True)#属于本项目的数据id
class Meta:
verbose_name='项目信息'
verbose_name_plural='项目信息'
permissions = ( #自定义的特殊权限
("can_drive", "自定权限1"),
("can_vote", "自定权限2"),
("can_drink", "自定权限3"),
)
def __str__(self):
return self.proname
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
我本以为是像这样的
可编辑的
但是最后结果却是
proparticipants和prodataids那里自动地就把所有的用户和所有的数据全都关联上了,且只能添加新的,不能增删修改,这是怎么回事?求大神指点。
Finally solved this problem, found it here: http://stackoverflow.com/ques...
You can take a look.
Django’s admin background renders the manytomanyfield field like this.
The associated data is deleted and modified in other tables. If you want to realize your own ideas, you should customize it yourself.
You need to override the default style
Reference
https://github.com/django/dja...
https://github.com/django/dja...