Metadata-Version: 2.0
Name: django-ktag
Version: 0.0.7
Summary: django tag input field 
Home-page: https://github.com/gojuukaze/django-ktag
Author: gojuukaze
Author-email: i@ikaze.uu.me
License: GUN V3.0
Platform: Any
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Framework :: Django
Classifier: Environment :: Web Environment
Requires-Python: >=3
Requires-Dist: Django (>=2.0.0)

django-ktag
==========================


django tag input field



`Home <https://github.com/gojuukaze/django-ktag>`__ | `Documentation <https://github.com/gojuukaze/django-ktag>`__




.. image:: https://github.com/gojuukaze/django-ktag/blob/master/demo.gif?raw=true

Install
----------------------

.. code-block:: shell

    pip install django-ktag

Requirements
----------------------

- python 3+
- django 2+


Quick Start
----------------------

The form class
***************

Our starting point for it in Django is this:

.. code-block:: python

    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:

.. code-block:: python

    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():
                print(form.cleaned_data['fruits'])
                return HttpResponse(str(form.cleaned_data['fruits']))

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


The template
**************

The simplest example is:

.. code-block:: python

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



