I intend to acquire the Python skill on web after years’ work on text processing, so I started with Flask by following Miguel Grinberg‘s instruction: The Flask Mega , you can learn how to integrate bootstrap with your project from the posts.
After that, you can learn how to integrate select2 with your project by reading <Flask Web开发:用Select2实现类似知乎的标签系统> as a guide.
here is a demo of select2.
Here some notes for the integration.
WTForms-SQLAlchemy 0.1SQLAlchemy 1.2.6
TypeError: $(...).select2 is not a function
I met this error at the start of integration, and found my answer from stackoverflow:
This error raises if your js files where you have bounded the select2 with select box is loading before select2 js files. Please make sure files should be in this order like..
- select2 js
- your js
I found that jquery was loaded inagain from developer Tools even if I have linked it in header, this has been mentioned in Flask Bootstrap official guide:
Q1.1 and 1.2 are more like tricks about how to use Flask Bootstrap blocks. Here is how I figure it out:
2.1 Flask-WTF and wtforms_sqlalchemy
I met following error when I try to organize <select>’s data from db query result
cls, key = identity_key(instance=obj)Here is the patch about the issue: https://github.com/kvesteri/wtforms-alchemy/pull/128/commits/4b20d130ca1480bd8697bf8ca80720d80150174f?diff=split
ValueError: too many values to unpack (expected 2)