views:

214

answers:

2

Hi!

I've been doing some models of a future app, and, after adding verbose_name and verbose_name_plural to every entry on a working model, for making it 'beautiful', I've found that at validate time, Django doesn't like that, so it says:

  File "/home/andor/Documentos/desarrollo/grundymanage/../grundymanage/concursantes/models.py", line 4, in <module>
    class Concursante(models.Model):
  File "/home/andor/Documentos/desarrollo/grundymanage/../grundymanage/concursantes/models.py", line 7, in Concursante
    nombre_artistico = models.CharField(verbose_name='Nombre Artístico', verbose_name_plural='Nombres Artísticos', max_length=50)
TypeError: __init__() got an unexpected keyword argument 'verbose_name_plural'

My model begins like this:

# -*- encoding: utf-8 -*-
from django.db import models

class Concursante(models.Model):
    nombre = models.CharField(verbose_name='Nombre', max_length=30)
    apellidos = models.CharField(verbose_name='Apellidos', max_length=50)
    nombre_artistico = models.CharField(verbose_name='Nombre Artístico', verbose_name_plural='Nombres Artísticos', max_length=50)

Why 'he' didn't expects a plural verbose name there? Cannot live together with verbose_name?

FYI, this are my software versions:

  • Ubuntu 8.04
  • Python 2.5.2
  • Django "1" "0" "final"
  • Django ubuntu package version "1.0-1ubuntu1"
+4  A: 

There is no verbose_name_plural. It does not make sense to have both singular and plural for one field. They are mutually exclusive. In Django, they share the same name: verbose_name.

If your data represents multiple items (e.g. in a one-to-many relationship) use a plural form in verbose_name. Otherwise, if your data represents a single item, use a singular form.

Verbose name fields in the Django documentation provides some examples.

strager
+1: Quote the documentation
S.Lott
+2  A: 

Unfortunately, verbose_name_plural is not an option on the field. It's a meta option for the model itself. A field has no plural name since, unless it's a many-to-many relationship (in which case Django will use the plural for the model pointed to by the relationship), there's only one entity in that field.

Here's the doc section: http://docs.djangoproject.com/en/dev/topics/db/models/#id3

Jarret Hardie