### Configure Followed Reverse Relations for Page Variants Source: https://github.com/wagtail/wagtail-transfer/blob/main/docs/settings.md Example of configuring followed reverse relations to account for page variants, specifically for the wagtail-personalisation library. ```python WAGTAILTRANSFER_FOLLOWED_REVERSE_RELATIONS = [ ('wagtailcore.page', 'personalisable_canonical_metadata', True), ] ``` -------------------------------- ### Preseed Specific ID Range for Retrospective Installation Source: https://github.com/wagtail/wagtail-transfer/blob/main/docs/management_commands.md When retrospectively installing wagtail-transfer on existing sites, use this command with a specified range to ensure common pages are handled as updates. This generates consistent UUIDs between site instances for the given ID range. ```bash ./manage.py preseed_transfer_table wagtailcore.page --range=1-199 ``` -------------------------------- ### Register Custom Serializer for a Model Source: https://github.com/wagtail/wagtail-transfer/blob/main/docs/settings.md Register a custom serializer for a specific model, such as `myapp.MyModel`, to control which fields are exported. This example shows how to ignore specific fields by extending the default `PageSerializer`. ```python # /wagtail_hooks.py from wagtail import hooks from wagtail_transfer.serializers import PageSerializer from myapp.models import MyModel class MyModelCustomSerializer(PageSerializer): ignored_fields = PageSerializer.ignored_fields + [ 'secret_field_1', 'environment_specific_data_field_123', ... ] pass @hooks.register('register_custom_serializers') def register_my_custom_serializer(): return {MyModel: MyModelCustomSerializer} ``` -------------------------------- ### Preseed Wagtail Core Page Model for Site Launch Source: https://github.com/wagtail/wagtail-transfer/blob/main/docs/management_commands.md Use this command on the staging environment before launching a site to ensure existing pages are updated rather than duplicated on the live site. This synchronizes the UUID table between staging and live environments. ```bash ./manage.py preseed_transfer_table wagtailcore.page ``` -------------------------------- ### Configure Basic Access Authentication Source: https://github.com/wagtail/wagtail-transfer/blob/main/README.md If a source site uses Basic Access Authentication, include the BASIC_AUTH_SECRET key with a tuple of (username, password) for secure access. ```python WAGTAILTRANSFER_SOURCES = { 'staging': { 'BASE_URL': 'https://staging.example.com/wagtail-transfer/', 'SECRET_KEY': '4ac4822149691395773b2a8942e1a472', 'BASIC_AUTH_SECRET': ('testing', 'super-secret'), }, } ``` -------------------------------- ### Configure Followed Reverse Relations for Import Source: https://github.com/wagtail/wagtail-transfer/blob/main/docs/settings.md Defines models, their reverse relations, and whether deletions should be synced during import. Useful for models like tags on non-Page models. ```python WAGTAILTRANSFER_FOLLOWED_REVERSE_RELATIONS = [('wagtailimages.image', 'tagged_items', True)] ``` -------------------------------- ### Include wagtail-transfer URLs Source: https://github.com/wagtail/wagtail-transfer/blob/main/docs/setup.md Add this import and URL pattern to your project's top-level urls.py to enable wagtail-transfer functionality. ```python from wagtail_transfer import urls as wagtailtransfer_urls url(r'^wagtail-transfer/', include(wagtailtransfer_urls)), ``` -------------------------------- ### Configure WAGTAILTRANSFER_SOURCES and WAGTAILTRANSFER_SECRET_KEY Source: https://github.com/wagtail/wagtail-transfer/blob/main/docs/setup.md Define source sites and secret keys in your project settings for authentication. It's recommended to use environment variables for secret keys. ```python WAGTAILTRANSFER_SOURCES = { 'staging': { 'BASE_URL': 'https://staging.example.com/wagtail-transfer/', 'SECRET_KEY': '4ac4822149691395773b2a8942e1a472', }, 'production': { 'BASE_URL': 'https://www.example.com/wagtail-transfer/', 'SECRET_KEY': 'a36476ffc6af34dc935570d97369eca0', }, } WAGTAILTRANSFER_SECRET_KEY = '7cd5de8229be75e1e0c2af8abc2ada7e' ``` -------------------------------- ### Preseed Transfer Table Command Usage Source: https://github.com/wagtail/wagtail-transfer/blob/main/docs/management_commands.md This command populates the UUID table with predictable values for specified models or apps. It ensures that objects within a given range are recognized as updates rather than new creations when transferring data between site instances. ```bash ./manage.py preseed_transfer_table [--range=MIN-MAX] model_or_app [model_or_app ...] ``` -------------------------------- ### Configure Wagtail Transfer Sources Source: https://github.com/wagtail/wagtail-transfer/blob/main/docs/settings.md Define `WAGTAILTRANSFER_SOURCES` as a dictionary to specify available sites for import, including their base URLs and secret keys. This allows Wagtail Transfer to connect to and authenticate with remote Wagtail sites. ```python WAGTAILTRANSFER_SOURCES = { 'staging': { 'BASE_URL': 'https://staging.example.com/wagtail-transfer/', 'SECRET_KEY': '4ac4822149691395773b2a8942e1a472', }, 'production': { 'BASE_URL': 'https://www.example.com/wagtail-transfer/', 'SECRET_KEY': 'a36476ffc6af34dc935570d97369eca0', }, } ``` -------------------------------- ### Set API Proxy Timeout for Chooser Source: https://github.com/wagtail/wagtail-transfer/blob/main/docs/settings.md Adjusts the timeout limit for API calls made to browse the page tree on the source server. Increase this if the default 5 seconds is too low. ```python WAGTAILTRANSFER_CHOOSER_API_PROXY_TIMEOUT = 5 ``` -------------------------------- ### Register Custom Field Adapter Source: https://github.com/wagtail/wagtail-transfer/blob/main/docs/settings.md Demonstrates how to register a custom field adapter for Wagtail Transfer using the `register_field_adapters` hook. This allows custom serialization and identification of field references. ```python # /wagtail_hooks.py from django.db import models from wagtail import hooks from wagtail_transfer.field_adapters import FieldAdapter class MyCustomAdapter(FieldAdapter): pass @hooks.register('register_field_adapters') def register_my_custom_adapter(): return {models.Field: MyCustomAdapter} ``` -------------------------------- ### Configure Followed Reverse Relations Source: https://github.com/wagtail/wagtail-transfer/blob/main/README.md Define custom reverse relations to follow during imports, especially when integrating with other Wagtail extensions like wagtail-personalisation. Ensure page variants are accounted for. ```python WAGTAILTRANSFER_FOLLOWED_REVERSE_RELATIONS = [ ('wagtailcore.page', 'personalisable_canonical_metadata', True), ] ``` -------------------------------- ### Preseed All Relevant Wagtail and Django Models Source: https://github.com/wagtail/wagtail-transfer/blob/main/docs/management_commands.md This command is typically sufficient to cover all standard models provided by Django and Wagtail. It assigns UUIDs to base models and related models linked through ParentalKey and InlinePanel. ```bash ./manage.py preseed_transfer_table auth wagtailcore wagtailimages.image wagtaildocs ``` -------------------------------- ### Default Wagtail Transfer Lookup Fields Source: https://github.com/wagtail/wagtail-transfer/blob/main/docs/settings.md The default `WAGTAILTRANSFER_LOOKUP_FIELDS` configuration includes settings for 'taggit.tag', 'wagtailcore.locale', and 'contenttypes.contenttype'. Overriding these, especially 'ContentType', may cause import issues. ```python { 'taggit.tag': ['slug'], 'wagtailcore.locale': ["language_code"], 'contenttypes.contenttype': ['app_label', 'model'], } ``` -------------------------------- ### Specify Models for Update Source: https://github.com/wagtail/wagtail-transfer/blob/main/docs/settings.md Use `WAGTAILTRANSFER_UPDATE_RELATED_MODELS` to list models that should be updated to their latest version from the source site during an import. This is useful for models that are integral to the imported content, like images. ```python WAGTAILTRANSFER_UPDATE_RELATED_MODELS = ['wagtailimages.image', 'adverts.advert'] ``` -------------------------------- ### Define Secret Key for Wagtail Transfer Source: https://github.com/wagtail/wagtail-transfer/blob/main/docs/settings.md Set the `WAGTAILTRANSFER_SECRET_KEY` to authenticate requests between sites for content import. Ensure the key matches on both the source and importing sites. ```python WAGTAILTRANSFER_SECRET_KEY = '7cd5de8229be75e1e0c2af8abc2ada7e' ``` -------------------------------- ### Configure Object Lookup Fields Source: https://github.com/wagtail/wagtail-transfer/blob/main/docs/settings.md Set `WAGTAILTRANSFER_LOOKUP_FIELDS` to specify fields used for object lookups on given models, enabling UUID-independent matching. This helps prevent duplicate records for models with unique identifying fields. ```python WAGTAILTRANSFER_LOOKUP_FIELDS = {'blog.author': ['first_name', 'surname']} ``` -------------------------------- ### Exclude Models from Import Association Source: https://github.com/wagtail/wagtail-transfer/blob/main/docs/settings.md Specifies models that should not be imported by association when referenced from imported content. This prevents recursive importing of linked objects. ```python WAGTAILTRANSFER_NO_FOLLOW_MODELS = ['wagtailcore.page', 'organisations.Company'] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.