Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

django tag input field

Project description

django tag input field

Home | Documentation


pip install django-ktag


  • python 3+
  • django 2+

Quick Start

  • The settings
  1. Add ‘ktag’ application to the INSTALLED_APPS
  1. Make sure APP_DIRS is True in TEMPLATES
'APP_DIRS': True,
  • The form class

Building a form in Django like this:

from django import forms
from ktag.fields import TagField

class TagForm(forms.Form):
    fruits = TagField(label='fruits', place_holder='write your fruits', delimiters=' ',
                      data_list=['apple', 'banana', 'watermelon', 'orange'], initial='grape coconut')
  • The view

To handle the form we need to instantiate it in the view for the URL where we want it to be published:

from django.http import HttpResponse
from django.shortcuts import render

from example.forms import TagForm

def index(request):
    if request.method == 'POST':
        form = TagForm(request.POST)
        if form.is_valid():
            return HttpResponse(str(form.cleaned_data['fruits']))

        form = TagForm()
    return render(request, 'index.html', {'form': form})
  • The template

The simplest example is:

<form action="" method="post">
    {% csrf_token %}
    {{ form }}
    <input type="submit" value="OK" style="font-size: larger">

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-ktag, version 1.0.3
Filename, size File type Python version Upload date Hashes
Filename, size django-ktag-1.0.3.tar.gz (23.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page