Auto-complete/auto-suggestion for django-taggit.
With django-taggit
, you can attach tags in any Django models. However, user experience is not that good as it uses
comma to separate multiple tags in same form field, and resulting in duplicate tags eg. Himalaya vs. Himalayas, Sublime-Text vs. Sublime Text etc.
And you probably want auto-complete/auto-suggest feature when user types some characters in tag field. Thanks to selectize.js, we got that covered :)
Install taggit-selectize::
pip install taggit-selectize
- Put
taggit-selectize
in settings:
INSTALLED_APPS = (
'django.contrib.admin',
...
...
'taggit_selectize',
)
- Update urls.py.
urlpatterns = patterns('',
...
url(r'^taggit/', include('taggit_selectize.urls')),
url(r'^admin/', include(admin.site.urls)),
...
)
- Create
admin
dir inside templates folder. Create a templatebase_site.html
and copy paste this. This has to override from project template dirs otherwise django will still load defaultbase_site.html
fromdjango.contrib.admin
app. Also, filesystem loader must be before app dir loader in settings like:
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
You can also use outside of admin in same way.
There is demo app included example_app
.
cd example_app
python manage.py migrate
python manage.py runserver
Login username: admin
password: admin