Django verbose_name of reverse relation

746 Views Asked by At

I have a model like:

class Question(models.Model):
    ...

class Answer(models.Model):
    question = models.ForeignKey(
        Question, null=False, blank=False, on_delete=models.CASCADE,
        related_name='answers',
        verbose_name='translated name'
)

I would now like to use the verbose_name in a template (as it is translated) over the reverse relation like

{{ question.answers.verbose_name }}. Unfortunately this does not work.

On the other hand {{ question.answers.related_name }} works.

So it seems that in the reverse_relation only the related_name is available.

Is there any way to get the verbose_name from the reverse relation?

1

There are 1 best solutions below

0
On BEST ANSWER

No verbose name is just to make the model name more readable. They are used if you want to make your model attribute more readable.

https://docs.djangoproject.com/en/3.1/ref/models/fields/#verbose-name

A human-readable name for the field. If the verbose name isn’t given, Django will automatically create it using the field’s attribute name, converting underscores to spaces. See Verbose field names.