Let's add translations for our product catalog. django-parler provides a TranslatedModel model class and a TranslatedFields wrapper to translate model fields. Edit the models.py file inside the shop application directory and add the following import:
from parler.models import TranslatableModel, TranslatedFields
Then, modify the Category model to make the name and slug fields translatable as follows:
class Category(TranslatableModel): translations = TranslatedFields( name = models.CharField(max_length=200, db_index=True), slug = models.SlugField(max_length=200, db_index=True, unique=True) )
The Category model now inherits from TranslatedModel instead of models.Model and both the name and slug fields are included in ...