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 ofget_result_label+get_selected_result_label.Create: the POST response returns an HTML label fragment, not
{"id": …, "text": …}JSON.Forwarding: the
forwardwidget argument anddal.forwardhelpers work identically.Admin registration:
ModelAdmin.formassignment works identically.Static files: replace
dal_select2media withdal_alightmedia; jQuery is no longer loaded by the widget.