Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Correctly generate plurals when using Django

Project Description

NAME

inflect_dj.py - Generate plurals for use with Django.

VERSION

This document describes version 0.2.0 of inflect_dj.py

INSTALLATION

pip install inflect_dj

or

easy_install inflect_dj

DESCRIPTION

@verbose_name_plural —

Decorator for the Django models.Model classes.

Decorating a child class of model.Model with @verbose_name_plural will ensure that the plural form of the model name will be rendered correctly.

It uses the module inflect.py to determine the correct pluralisation.

USAGE

  1. Using @verbose_name_plural when specifying a verbose_name for the model:

    from django.db import models
    from inflect_dj import verbose_name_plural
    
    @verbose_name_plural
    class mycategory(models.Model):
        [definition of the model]
        class Meta:
            verbose_name = 'category'
            [rest of the Meta class definition]
    
The plural will be displayed correctly as categories.
  1. Using @verbose_name_plural without specifying verbose_name:

    from django.db import models
    from inflect_dj import verbose_name_plural
    
    @verbose_name_plural
    class category(models.Model):
        [definition of the model]
        class Meta:
            [class Meta definition]
    
The plural will be displayed correctly as categories, as this is the plural of the class name.

Earlier versions of Python

If you are using a Python version earlier than 2.6 you cannot use class decorators and must explicitly redefine the class with a call to verbose_name_plural():

from django.db import models
from inflect_dj import verbose_name_plural

class mycategory(models.Model):
    [definition of the model]
    class Meta:
        verbose_name = 'category'
        [rest of the Meta class definition]
mycategory = verbose_name_plural(mycategory)

AUTHOR

Paul Dyson (pwdyson@yahoo.com)

Release History

Release History

This version
History Node

v0.2.0

History Node

v0.1.2

History Node

v0.1.1

History Node

v0.1.0a

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
inflect_dj-v0.2.0.tar.gz (14.7 kB) Copy SHA256 Checksum SHA256 Source Aug 7, 2010

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting