Skip to content

Commit

Permalink
Chapter 2
Browse files Browse the repository at this point in the history
  • Loading branch information
shabda committed Feb 1, 2018
1 parent 898d805 commit 7bd1883
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
Binary file added docs/images/plural.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/plural_fixed.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions docs/plural_text.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
How to set the plural text for a model?
===========================================================

By default admin will show the name of your model appended with an "s", aka the plural form of your model. It looks like this

.. image:: images/plural.png

You have been asked to set the correct plural spellings: `Categories` and `Heroes`

You can do this by setting the :code:`verbose_name_plural` in your models. Change that in your models.py.::


class Category(models.Model):
...

class Meta:
verbose_name_plural = "Categories"


class Hero(Entity):
...

class Meta:
verbose_name_plural = "Heroes"


.. image:: images/plural_fixed.png
6 changes: 6 additions & 0 deletions heroes_and_monsters/entities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
class Category(models.Model):
name = models.CharField(max_length=100)

class Meta:
verbose_name_plural = "Categories"


class Origin(models.Model):
name = models.CharField(max_length=100)
Expand Down Expand Up @@ -38,6 +41,9 @@ class Meta:

class Hero(Entity):

class Meta:
verbose_name_plural = "Heroes"

is_immortal = models.BooleanField(default=True)

benevolence_factor = models.PositiveSmallIntegerField(
Expand Down

0 comments on commit 7bd1883

Please sign in to comment.