Django-autocomplete-light 的使用
注意⚠️:这里使用的 Django-autocomplete-light==3.5.1, django > 2.0
- 安装 Django-autocomplete-light
pip install Django-autocomplete-light -i https://pypi.douban.com/simple
- setting 中添加 Django-autocomplete-light
INSTALLED_APPS = [
'dal',
'dal_select2',
'django.contrib.admin',
.....
- App 中 url 添加url 路由
from dal import autocomplete
from django.conf.urls import url
from .models import Report
urlpatterns = [
url(
'report/$',
autocomplete.Select2QuerySetView.as_view(model=Report),
name='report',
)
]
- result