django实现select2效果

效果图:

django-select2-forms

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/

相关文章:

  • 2021-12-27
  • 2022-12-23
  • 2021-10-14
  • 2021-09-20
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-11-22
  • 2021-09-26
  • 2021-10-24
  • 2022-12-23
  • 2021-10-19
  • 2021-05-25
  • 2021-05-31
相关资源
相似解决方案