Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
jQuery Tokeninput for Django forms
Python CSS HTML JavaScript
branch: master

Merge pull request #1 from puterleat/master

Fixed urls imports for Django 1.6 and above.
latest commit 5f4a8ec9c6
@adammck authored

jQuery Tokeninput for Django

This is reusable Django app which provides TokenField as a drop-in replacement for ModelMultipleChoiceField. It wraps the excellent jQuery Tokeninput plugin, which is by James Smith.

Quick Start

I haven't packaged this yet, so install it via GitHub for now:

$ pip install -e git://

Add it to your INSTALLED_APPS:

  # ...

Add the generic search view to your urlpatterns:

urlpatterns = patterns("",
  # ...
  url(r"^djtokeninput/", include("djtokeninput.urls"))

Add a search method to your model:

from django.db import models

class Tag(models.Model):
  name = models.CharField(max_length=100)

  def search(cls, query):
    return cls.objects.filter(name__icontains=query)

Add a TokenField to your form:

from django import forms
from djtokeninput import TokenField

class ExampleForm(forms.Form):
  title = forms.CharField()
  desc = forms.CharField(widget=forms.Textarea)
  tags = TokenField(models.Tag, required=False)

Finally, add the JS and CSS assets to your template:

  <link rel="stylesheet" href="/static/css/token-input.css">
  <script src="//"></script>
  <script src="/static/js/jquery-tokeninput-1.6.0-min.js"></script>
  <script src="/static/js/djtokeninput.js"></script>

Form Media

You can also use Form Media if you're into that. Just include {{ }} in your <head> as usual.

I prefer to explicity include all of my assets in my base template, and pack them with Django Compressor.


You can configure the Tokeninput by passing a TokenWidget instance to TokenField:

tags = TokenField(models.Tag, required=False,
    hint_text="Search for tags",

The jQuery Tokeninput docs contains the list of available settings.


  • Django >= 1.3
  • jQuery >= 1.5


djtokeninput is free software, available under the MIT license.

Something went wrong with that request. Please try again.