Skip to main content

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

Project description

django_select2_autofill

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

This allows for an end-user to more efficiently input new data in instances where multiple field values may be shared across formset forms.

Install

  1. With a Django project virtual environment activated:

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

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

    from django import admin
    from django import 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.models import CustomModel
    
    
    # ...
    widgets = {
        "model_field_name": AutofillAutocompleteSelect(
            CustomModel.model_field_name.field, CustomAdminSite()
        ),
    }
    

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_select2_autofill-0.1.2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_select2_autofill-0.1.2-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file django_select2_autofill-0.1.2.tar.gz.

File metadata

  • Download URL: django_select2_autofill-0.1.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for django_select2_autofill-0.1.2.tar.gz
Algorithm Hash digest
SHA256 526bd987ccab6e7f57e27283c0db1a09a6220ed07058ed0fe27ab65f39f35b31
MD5 79c418c5f75c4b29f722957176d5ff3d
BLAKE2b-256 adb245764374633f4b66ff7cf6d73c8b0c45865e630b3d4c703038b2adf007a7

See more details on using hashes here.

File details

Details for the file django_select2_autofill-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_select2_autofill-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 273e73dff91a8d24576266318d6dea0bfd3b585852c2cc6116c99b41d1215f60
MD5 58755a2cf4ef13967f9ed5751f761a5c
BLAKE2b-256 955f885345bf8b83264cec09895767af6295702ffadf5a7654a3e26a85c84d49

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page