django-select2-forms

django实现select2效果

效果图:

django-select2-forms_第1张图片

pip install django-select2-forms

settings里面加上

INSTALLED_APPS = (
    # ...
    'select2',
)

urls里面加上

urlpatterns = patterns('',
    # ...
    url(r'^select2/', include('select2.urls')),
)

接下来把models里面的model外键改为

class Entry(models.Model):
    author = select2.fields.ForeignKey(Author,
        overlay="Choose an author...")

运行项目,访问页面,就是指定的字段就是上图中的效果了

本文参考地址:https://pypi.org/project/django-select2-forms/1.1.25/

你可能感兴趣的:(django,python)