[Django]-Verbose_name_plural Naming convention

3πŸ‘

βœ…

In short: it does not matter much since this has no effects on the coding side of the program. It is used to communicate with the user. Here probably the best option is 'items for sale'.

The verbose_name_plural [Django-doc] is a human readable name you give to the objects.

So it makes sense to define this as:

class ItemForSale(models.Model):
    # ...

    class Meta:
        verbose_name = 'item for sale'
        verbose_name_plural = 'items for sale'

You can use this in forms, dialogs, and other means to communicate with the user. There are no naming conventions (like PEP-8 for example), since this deals with communication between the app and the user.

Its twin verbose_name [Django-doc] for example specifies that:

Options.verbose_name

A human-readable name for the object, singular:

verbose_name = "pizza"

If this isn’t given, Django will use a munged version of the class
name: CamelCase becomes camel case.

2πŸ‘

You could take a look at Django Admin to check how the words will be shown.
Another example could be:

class Property(models.Model):
  ...
  class Meta:
    verbose_name = 'property'
    verbose_name_plural = 'properties'

Leave a comment