پیادهسازی MultiSelectField با Select2 در ادمین جنگو — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited پیادهسازی MultiSelectField با Select2 در ادمین جنگو (Agent Skill) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
این مهارت برای پیکربندی پنل ادمین جنگو جهت استفاده از ویجت Select2 برای فیلدهای MultiSelectField استفاده میشود تا رابط کاربری بهتری (جستجوپذیر و فشرده) نسبت به چکباکسهای پیشفرض فراهم شود.
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.
MultiSelectField from multiselectfield in the model.get_choices()) that query the database to generate choices dynamically: [(item.id, item.name) for item in Model.objects.all()].ModelForm in admin.py.Meta class of the form, override the widgets dictionary. Assign Select2MultipleWidget to the MultiSelectField fields.ModelAdmin class uses the custom form via the form attribute.CheckboxSelectMultiple for large datasets or when a searchable interface is required.CheckboxSelectMultiple widgets if the user requires a compact or searchable interface.# 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~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.