I am curious, since there is select2 implementation in Django admin using autocomplete_fields, why it is not also available outside of admin to my apps?
I am using django-select2 but keep wondering myself am I doing this wrong and cant find any answers around.
EDIT
As requested, this are code snippets on how I use django-select2 currently with Django 3.0.6. I have quickly found one that I use with inlineformset_factory, that works:
settings.py
INSTALLED_APPS = [
...,
'django_select2',
]
urls.py
...
path("select2/", include("django_select2.urls")),
...
forms.py
class SiteMaterialDetailsForm(forms.ModelForm):
class Meta:
model = SiteMaterialDetails
fields = '__all__'
widgets = {
'material': Select2Widget,
}
models.py
class SiteMaterialDetails(models.Model):
sitematerial = models.ForeignKey(SiteMaterial, on_delete=models.CASCADE)
material = models.ForeignKey(Material, on_delete=models.CASCADE)
quantity = models.IntegerField(default=0)
in template
{% block head %}
{{ block.super }}
{{ formset.media.css }}
{% endblock %}
...
{{ formset.media.js }}
Hope it does make sense :)