🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

django-select2-autofill

Package Overview
Dependencies
Maintainers
0
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

django-select2-autofill

A django app to autofill Select2 fields in admin inline forms.

0.1.4
PyPI
Maintainers
0

django_select2_autofill

django_select2_autofill is a Django app that allows newly added Django admin inline form autocomplete fields to be automatically filled with data from the last user-selected option of the same autocomplete field in a form produced by a shared formset.

This allows end-users to more efficiently input new data in instances where one value may be shared across ModelAdmin formset form autocomplete fields.

Install

  • With a Django project virtual environment activated:

    python -m pip install django-select2-autofill
    
  • Add django_select2_autofill to your Django INSTALLED_APPS setting:

    INSTALLED_APPS = [
       # ...
       "django_select2_autofill",
    ]
    
  • Use the AutofillAutocompleteSelect widget in the ModelForm containing autocomplete_fields:

    from django import admin, forms
    from django_select2_autofill import AutofillAutocompleteSelect
    
    
    class CustomForm(forms.ModelForm):
        class Meta:
            widgets = {
                "model_field_name": AutofillAutocompleteSelect(
                    CustomModel.model_field_name.field, admin.site
                ),
            }
    

    Note that admin.site can be replaced with a custom AdminSite instance, if necessary:

    # ...
    from app.admin import CustomAdminSite
    
    
    # ...
    widgets = {
        "model_field_name": AutofillAutocompleteSelect(
            CustomModel.model_field_name.field, CustomAdminSite()
        ),
    }
    

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts