Reputation: 743
I'm looking to add a human-readable name to a manytomanyfield that will be displayed in a modelform. I've already been here: django display content of a manytomanyfield and that solution doesn't work for modelfields, unless I've misunderstood. I'm sure there's a way to do it, I just haven't been able to figure it out. Does anyone know?
Upvotes: 2
Views: 4189
Reputation: 53991
Do you mean a verbose_name field attribute?
foo = models.ManyToManyField("app.Model", ..., verbose_name="bar")
Upvotes: 2
Reputation: 2175
You can try it this way:
class A(models.Model):
foo = models.CharField("Foo", max_length = 20)
class Meta:
verbose_name = "Human-readable"
verbose_name_plural = "Human-readable"
class B(models.Model):
bars = models.ManyToManyField(A, related_name='if_you_need')
Your bars field should display as "Human-readable".
Upvotes: 1