我希望我错了,但是在我看来,对于ManyToManyField没有help_text
的唯一方法是为表单编写__init__
方法并覆盖self.fields[fieldname].help_text
。那真的是唯一的方法吗?我更喜欢使用CheckboxSelectMultple
小部件,所以我真的必须为使用__init__
的任何形式定义ManyToManyField
方法吗?
class ManyToManyField(RelatedField, Field):
description = _("Many-to-many relationship")
def __init__(self, to, **kwargs):
#some other stuff
msg = _('Hold down "Control", or "Command" on a Mac, to select more than one.')
self.help_text = string_concat(self.help_text, ' ', msg)
最佳答案
class Item(models.Model):
...
category = models.ManyToManyField(Category, null=True,blank=True)
category.help_text = ''
...
关于python - Django(1.2)表单: ManyToManyField Help Text,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3242174/