Integrating translations in the administration site

django-parler integrates smoothly with the Django administration site. It includes a TranslatableAdmin class that overrides the ModelAdmin class provided by Django to manage model translations.

Edit the admin.py file of the shop application and add the following import to it:

from parler.admin import TranslatableAdmin

Modify the CategoryAdmin and ProductAdmin classes to inherit from TranslatableAdmin instead of ModelAdmin. django-parler doesn't support the prepopulated_fields attribute, but it does support the get_prepopulated_fields() method that provides the same functionality. Let's change this accordingly. Edit the admin.py file to make it look as follows:

from django.contrib import ...

Get Django 2 by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.