Search code examples
pythondjangodjango-formsmanytomanyfield

Django (1.2) Forms: ManyToManyField Help Text


I hope I'm wrong, but it looks to me like the only way to have no help_text for a ManyToManyField is write an __init__ method for the form and overwrite self.fields[fieldname].help_text. Is that really the only way? I prefer to use CheckboxSelectMultple widgets, so am I really going to have to define an __init__ method for any form that uses a 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)

Solution

  • class Item(models.Model):
        ...
        category = models.ManyToManyField(Category, null=True,blank=True)
        category.help_text = ''
        ...