Migrating from dal_select2 to dal_alight

This guide helps you migrate an existing dal_select2 project to dal_alight. It’s not a requirement, but it’s supposed to be doable.

Why migrate

dal_select2 depends on jQuery, which puts the developer in charge of the JavaScript object lifecycle. dal_alight uses native Web Components with no external library dependency — no jQuery required.

Class name mapping

Replace Select2 with its Alight counterpart in your views, widgets, and form fields.

Behavioural differences

  • Response format: Select2 views return JSON; alight views return HTML fragments. Override get_result_label() instead of get_result_label + get_selected_result_label.

  • Create: the POST response returns an HTML label fragment, not {"id": …, "text": …} JSON.

  • Forwarding: the forward widget argument and dal.forward helpers work identically.

  • Admin registration: ModelAdmin.form assignment works identically.

  • Static files: replace dal_select2 media with dal_alight media; jQuery is no longer loaded by the widget.