Skip to content
Python JavaScript CSS HTML
Find file
Latest commit ce163c0 Apr 20, 2016 @WoLpH dropping python 3.2 support
Failed to load latest commit information.
docs updated docs Nov 27, 2014
example added django 1.9 and python 3.5 support Apr 20, 2016
tags_input added django 1.9 and python 3.5 support Apr 20, 2016
.coveragerc added python 2.6, 2.7, 3.2, 3.3, 3.3, pypy and pypy3 tests Nov 20, 2014
.gitignore
.travis.yml apparently django 17 tests are failing too now... Jul 8, 2015
MANIFEST.in fixed packageing Jun 25, 2012
README.rst added django 1.8 support to fix #6 Jul 7, 2015
pytest.ini added django 1.9 and python 3.5 support Apr 20, 2016
requirements.txt
requirements_test.txt added django 1.9 and python 3.5 support Apr 20, 2016
setup.cfg fixed tox Nov 20, 2014
setup.py fixing tests and fixing version so it wont break spontaneously again... Mar 11, 2015
tox.ini dropping python 3.2 support Apr 20, 2016

README.rst

Overview

Django Tags Input is a module that gives you a modified version of the Xoxco jQuery Tags Input library within Django.

The result is a very pretty interface with tags and autocomplete which can optionally automatically create new items when they are missing.

One of the most useful features of Django Tags Input is that it stores the elements in the order which you input.

So if you insert B, A, C into the database, it will return it sorted the way you entered it: B, A, C.

https://raw.githubusercontent.com/WoLpH/django-tags-input/master/docs/example.png

Links

How to install

Installing this module only takes a couple of minutes.

Currently Django 1.4, Django 1.5, Django 1.6, Django 1.7 and Django 1.8 are supported in combination with Python 2.6 and 2.7. Python 3.2, 3.3 and 3.4. Pypy and Pypy3.

  1. Install the module itself

    pip install django-tags-input

    # or

    easy_install django-tags-input

  2. Add tags_input to your INSTALLED_APPS setting in the Django settings.py.

    Example:

    INSTALLED_APPS = (
        # ... your other installed apps
        'tags_input',
    )
  3. Add the mappings to your settings.py file:

    Example:

    TAGS_INPUT_MAPPINGS = {
        'some_app.SomeKeyword': {
            'field': 'some_field',
        },
        'some_app.SomeOtherKeyword': {
            'fields': ('some_field', 'some_other_field'),
        },
        'some_app.SomeSortedKeyword': {
            'field': 'some_field',
            'ordering': [
                'some_field',
                'some_other_field',
            ],
            'filters': {
                'some_field__istartswith': 'a',
            },
            'excludes': {
                'some_field__iexact': 'foobar',
            },
        },
        'some_app.SomeCreateableKeyword': {
            'field': 'some_field',
            'create_missing': True,
        },
    }
  4. Add the tags_input urls to your urls.py:

    Example:

    from django.conf import urls
    
    urlpatterns = patterns('',
        url(r'^tags_input/', include('tags_input.urls', namespace='tags_input')),
        # ... other urls ...
    )

Admin usage

from django.contrib import admin
import models
from tags_input import admin as tags_input_admin

class YourAdmin(tags_input_admin.TagsInputAdmin):
    pass

admin.site.register(models.YourModel, YourAdmin)

Quickstart

To test the project simply clone the repository, install and run the example:

mkvirtualenv django-tags-input
git clone https://github.com/WoLpH/django-tags-input.git
pip install -e django-tags-input
cd django-tags-input/example
python manage.py runserver

Now you can go to http://localhost:8000/admin/ and login with username and password admin and admin respectively.

After this you can try adding some extra Foo objects through the Spam admin here: http://localhost:8000/admin/autocompletionexample/spam/2/

Note that some parts of the example are deliberately broken to test the behaviour in broken environments.

Something went wrong with that request. Please try again.