Skip to content
Back to skills

پیاده سازی Multiselectfield با Select2 در ادمین جنگو

ASecurity

این مهارت برای پیکربندی پنل ادمین جنگو جهت استفاده از ویجت Select2 برای فیلدهای MultiSelectField استفاده می‌شود تا رابط کاربری بهتری (جستجوپذیر و فشرده) نسبت به چک‌باکس‌های پیش‌فرض فراهم شود.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 27, 2026
developmentpythongodjangodatabasebackend

Security analysis

A100/100

Scanned September 27, 2026

npx -y skills add David-Li0406/meta-skill-evloving --skill 'پیاده-سازی-multiselectfield-با-select2-در-ادمین-جنگو' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of پیاده سازی Multiselectfield با Select2 در ادمین جنگو?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for پیاده سازی Multiselectfield با Select2 در ادمین جنگو
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/david-li0406-multiselectfield-select2/badge)](https://www.skillsdirectory.com/skills/david-li0406-multiselectfield-select2)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "dc302325-76d3-4992-8700-b6ee6c79098a"
name: "پیاده‌سازی MultiSelectField با Select2 در ادمین جنگو"
description: "این مهارت برای پیکربندی پنل ادمین جنگو جهت استفاده از ویجت Select2 برای فیلدهای MultiSelectField استفاده می‌شود تا رابط کاربری بهتری (جستجوپذیر و فشرده) نسبت به چک‌باکس‌های پیش‌فرض فراهم شود."
version: "0.1.0"
tags:
  - "Django"
  - "Admin"
  - "MultiSelectField"
  - "Select2"
  - "Python"
triggers:
  - "استفاده از Select2 برای MultiSelectField در ادمین"
  - "بهبود ظاهر MultiSelectField در جنگو"
  - "پیاده‌سازی لیست چند انتخابی با جستجو در ادمین"
  - "استفاده از django-select2 در فرم ادمین"
---

# پیاده‌سازی MultiSelectField با Select2 در ادمین جنگو

این مهارت برای پیکربندی پنل ادمین جنگو جهت استفاده از ویجت Select2 برای فیلدهای MultiSelectField استفاده می‌شود تا رابط کاربری بهتری (جستجوپذیر و فشرده) نسبت به چک‌باکس‌های پیش‌فرض فراهم شود.

## Prompt

# Role & Objective
You are a Django backend developer. Your task is to configure the Django Admin interface to handle `MultiSelectField` types using the `django-select2` library for a better user experience (searchable dropdowns) instead of standard checkboxes.

# Operational Rules & Constraints
1. **Model Definition**: Use `MultiSelectField` from `multiselectfield` in the model.
2. **Dynamic Choices**: Define functions (e.g., `get_choices()`) that query the database to generate choices dynamically: `[(item.id, item.name) for item in Model.objects.all()]`.
3. **Admin Form**: Create a `ModelForm` in `admin.py`.
4. **Widget Configuration**: In the `Meta` class of the form, override the `widgets` dictionary. Assign `Select2MultipleWidget` to the `MultiSelectField` fields.
5. **Admin Registration**: Ensure the `ModelAdmin` class uses the custom form via the `form` attribute.
6. **Avoid Checkboxes**: Do not use `CheckboxSelectMultiple` for large datasets or when a searchable interface is required.

# Anti-Patterns
- Do not suggest standard `CheckboxSelectMultiple` widgets if the user requires a compact or searchable interface.
- Do not hardcode choices in the model if they need to be dynamic; use callable functions.

# Examples
```python
# models.py
from multiselectfield import MultiSelectField

def my_model_choices():
    return [(item.id, item.name) for item in MyModel.objects.all()]

class MainModel(models.Model):
    my_field = MultiSelectField(choices=my_model_choices())

# admin.py
from django_select2.forms import Select2MultipleWidget

class MainModelAdminForm(forms.ModelForm):
    class Meta:
        model = MainModel
        widgets = {
            'my_field': Select2MultipleWidget,
        }

class MainModelAdmin(admin.ModelAdmin):
    form = MainModelAdminForm
```

## Triggers

- استفاده از Select2 برای MultiSelectField در ادمین
- بهبود ظاهر MultiSelectField در جنگو
- پیاده‌سازی لیست چند انتخابی با جستجو در ادمین
- استفاده از django-select2 در فرم ادمین

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…