Services Blog Français

Porting ModelForm enhancements from django-autocomplete-light v2 to Django

| by jpic | python django django-autocomplete-light xmodelform

Currently, django-autocomplete-light v2 provides enhancement to default form field generation for model fields, depending on the registered autocompletes, as shown in the tutorial.

For v3, we don’t want this feature inside DAL anymore because it has really nothing to do with autocomplete. Instead, I’m trying to contribute a generic way to do that. It would not benefit only django-autocomplete-light anymore, but all Django apps. You could get enhanced default form fields for model fields just by installing and configuring apps in your project.

My previous PoC lives in a separate app (xmodelform), but again it requires to override the ModelForm everywhere. My latest PoC on this is a 3 line change in Django to replace hardcoded defaults with instance attributes, and allows to change the default “Select” widget for a relation model field either in, either in

Please participate to the discussion and show community involvement to improve Django not only for our apps, but for everybody.

They trust us