Skip to main content

Integrate django-modeltranslation with

Project description

Django modeltranslation-lokalise

Integrate django-modeltranslation with It will let your project upload translatable fields of your model into using it's API and also update your local translations when someone updates them on lokalise. Currently suppors Lokalise-api v2 (thanks to @ddomenech).


pip install modeltranslation-lokalise

modeltranslation_lokalise depends on Django's contribtypes application, so make sure you include it in your INSTALLED_APPS setting before modeltranslation_lokalise:


You need to provide your lokalise proyect id and your api key in order to let modeltranslation_lokalise properly update your translations.


If you want to get your models updated automatically when someone updates them on lokalise, enable it by adding the view to your conf. Note that currently only translation.updated is supported:

from modeltranslation_lokalise import TranslationWebhookView

urlpatterns = [
    path('api/translations/', TranslationWebhookView.as_view(), name='translation_webhook'),

You also need to make migrations in order to create the necessary tables on your database to handle the translations:

python makemigrations
python migrate

How to use

Instead of using modeltranslation translator.register, you should use modeltranslation_lokalise.register_translation:

from modeltranslation.translator import TranslationOptions
from modeltranslation_lokalise.signals import register_translation

from your_app.models import Model1

class Model1TranslationOptions(TranslationOptions):
    fields = ('name', 'description',)

register_translation(Model1, Model1TranslationOptions)

And that's all, modeltranslations-lokalise will keep track of changes on your translatable models and import them in your lokalise project each time you update one of your translatable fields.

Non-lokalise translatable fields

It's possible that you want certain fields to be translatable in terms of modeltranslations but exclude them from being uploaded to Lokalise. In that case you can add an attribute non_lokalise_fields to your TranslationOptions object. Modeltranslation-lokalise will not track changes on that fields.

class ProductTranslationOptions(TranslationOptions):
    non_lokalise_fields = ('slug', )
    fields = ('title', 'description', ) + non_lokalise_fields


This project is licensed under the MIT License - see the LICENSE file for details

Project details

Download files

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

Files for modeltranslation-lokalise, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size modeltranslation-lokalise-0.2.0.tar.gz (6.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page