using django model translation with django rest

  1. Install the django-modeltranslation package using pip:

bash pip install django-modeltranslation

  1. Add 'modeltranslation' to the list of installed apps in your Django settings file:

python INSTALLED_APPS = [ ... 'modeltranslation', ... ]

  1. Define the languages you want to use in the LANGUAGES setting in your Django settings file:

```python from django.utils.translation import gettext_lazy as _

LANGUAGES = [ ('en', ('English')), ('es', ('Spanish')), # Add more languages as needed ] ```

  1. Add the necessary settings for modeltranslation in your Django settings file:

```python from modeltranslation import gettext as _

# Example settings MODELTRANSLATION_DEFAULT_LANGUAGE = 'en' MODELTRANSLATION_LANGUAGES = ('en', 'es') ```

  1. Register the models you want to translate in the model's admin file using the register decorator:

```python from modeltranslation.admin import TranslationAdmin

@admin.register(YourModel) class YourModelTranslationAdmin(TranslationAdmin): pass ```

  1. Create translation fields in your model by adding the TranslatedFields to your model definition:

```python from modeltranslation.models import TranslatedFields

class YourModel(models.Model): translations = TranslatedFields( title=models.CharField(max_length=200), description=models.TextField(), # Add more fields as needed ) ```