Skip to content

Enabling easy_select2 for FilePathField field #113

@tropicrainforest

Description

@tropicrainforest

Dear @asyncee,

I need to have a select2 widget in the Django administrator for the FilePathField field. I looked at the source code and for this purpose, we just need to have another condition along with CharField and ForeignKey in select2_modelform_meta function utils.py.

from django.db.models import ForeignKey, FilePathField

def select2_modelform_meta(model,
                           meta_fields=None,
                           widgets=None,
                           attrs=None,
                           **kwargs):
.
.
.
    for field in model._meta.fields:
        if isinstance(field, ForeignKey) or field.choices or isinstance(field, FilePathField):
            widgets.update({field.name: Select2(select2attrs=attrs)})

I didn't have permission to push it to a new branch. If possible, please enable the select2 widget to FilePathField.

Cheers
Mo

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions