Management Commands¶
wagtail_modeltranslation¶
wagtail_modeltranslation module adds the following management commands.
The update_translation_fields Command¶
This command is a proxy to django-modeltranslation’s own update_translation_fields, for more details read the
corresponding documentation on django-modeltranslation docs.
In case modeltranslation was installed in an existing project and you have specified to translate fields of models which are already synced to the database, you have to update your database schema.
Unfortunately the newly added translation fields on the model will be empty
then, and your templates will show the translated value of the fields which
will be empty in this case. To correctly initialize the default translation
field you can use the update_translation_fields command:
$ python manage.py update_translation_fields
The sync_page_translation_fields Command¶
New in version 0.8.
This command compares the database and translated Page model definition (finding new translation
fields) and provides SQL statements to alter wagtailcore_page table. You should run this command
after installation and after adding a new language to your settings.LANGUAGES.
$ python manage.py sync_page_translation_fields
The makemigrations_translation Command¶
New in version 0.8.
wagtail-modeltranslation patches Wagtail’s Page model and as consequence Django’s original
makemigrations commmand will create migrations for Page which may create conflicts with
other migrations. To circumvent this issue makemigrations_translation hides any Page model changes
and creates all other migrations as usual. Use this command as an alternative to Django’s own
makemigrations or consider using The makemigrations Command.
$ python manage.py makemigrations_translation
The migrate_translation Command¶
New in version 0.8.
Since The makemigrations_translation Command hides any Page model changes, Django’s own
migrate command won’t be able to update wagtailcore_page table with new translation fields. In order to
correctly update the database schema a combination of migrate followed by sync_page_translation_fields
is usually required. migrate_translation provides a shortcut to running these two commands. Use this
as an alternative to Django’s own migrate or consider using The migrate Command.
$ python manage.py migrate_translation
The set_translation_url_paths Command¶
Updates url_path translation fields for all pages.
$ python manage.py set_translation_url_paths
wagtail_modeltranslation.makemigrations¶
To use wagtail_modeltranslation.makemigrations module commands add 'wagtail_modeltranslation.makemigrations,'
to INSTALLED_APPS. This module adds the following management commands.
The makemigrations Command¶
This command is a proxy for The makemigrations_translation Command. It has the added benefit of
overriding Django’s own makemigrations allowing you to run makemigrations safely without creating
spurious Page migrations.
$ python manage.py makemigrations
The makemigrations_original Command¶
Since Django’s makemigrations is overriden by wagtail-modeltranslation’s version use
makemigrations_original to run the Django’s original makemigrations command. Please note
this will likely create invalid Page migrations, do this only if you know what you’re doing.
$ python manage.py makemigrations_original
wagtail_modeltranslation.migrate¶
To use wagtail_modeltranslation.migrate module commands add 'wagtail_modeltranslation.migrate,'
to INSTALLED_APPS. This module adds the following management commands.
The migrate Command¶
This command is a proxy for The migrate_translation Command. It has the added benefit of
overriding Django’s own migrate saving the need to additionally run sync_page_translation_fields.
See issue #175 to understand
how this command can be used to create translation fields in a test database.
$ python manage.py migrate
The migrate_original Command¶
Since Django’s migrate is overriden by wagtail-modeltranslation’s version use
migrate_original to run the Django’s original migrate command. Please note
this will not update wagtailcore_page table with new translation fields, use
sync_page_translation_fields for that.
$ python manage.py migrate_original