Skip to content
Browse files

Documented TextWidget usage

  • Loading branch information...
1 parent 9df7fde commit fc7902861fd9501d7634c09e0a35538ba490bd25 @jpic jpic committed
Showing with 54 additions and 0 deletions.
  1. +51 −0 docs/source/charfield.rst
  2. +3 −0 docs/source/index.rst
View
51 docs/source/charfield.rst
@@ -0,0 +1,51 @@
+.. _charfield:
+
+CharField autocompletes
+=======================
+
+`django-tagging
+<http://code.google.com/p/django-tagging/>`_ and derivates like `django-tagging-ng
+<https://github.com/svetlyak40wt/django-tagging-ng>`_ provide a ``TagField``,
+which is a ``CharField`` expecting comma separated tags. Behind the scenes,
+this field is parsed and ``Tag`` model instances are created and/or linked.
+
+A stripped variant of ``widget.js``, ``text_widget.js``, enables autocompletion
+for such a field. To make it even easier, a stripped variant of ``Widget``,
+``TextWidget``, automates configuration of ``text_widget.js``.
+
+Needless to say, ``TextWidget`` and ``text_widget.js`` have a structure that
+is consistent with ``Widget`` and ``widget.js``.
+
+It doesn't have many features for now, but feel free to participate to the
+`project on GitHub
+<https://github.com/yourlabs/django-autocomplete-light>`_.
+
+As usual, a working example lives in test_project. in app
+``charfield_autocomplete``.
+
+Example
+-------
+
+This demonstrates a working usage of TextWidget:
+
+.. literalinclude:: ../../test_project/charfield_autocomplete/forms.py
+ :language: python
+
+FTR, using the form in the admin is still as easy:
+
+.. literalinclude:: ../../test_project/charfield_autocomplete/admin.py
+ :language: python
+
+So is registering an Autocomplete for Tag:
+
+.. literalinclude:: ../../test_project/charfield_autocomplete/autocomplete_light_registry.py
+ :language: python
+
+Upgrading from previous versions
+--------------------------------
+
+Note that if you have customized ``autocomplete_light/static.html``, you have
+to update it to include ``text_widget.js``. FTR, this is what it looks like:
+
+.. literalinclude:: ../../autocomplete_light/templates/autocomplete_light/static.html
+ :language: django
View
3 docs/source/index.rst
@@ -12,6 +12,8 @@ This app fills all your ajax autocomplete needs:
- **GenericForeignKey** fully :ref:`supported<generic-fk>`
- **django-generic-m2m** support, yes that's a :ref:`generic M2M relation
<generic-m2m>`!
+- **CharField autocomplete** support, :ref:`comma separated values
+ <charfield>`, useful for tags field,
- **APIs** powered autocomplete support, proposing :ref:`results that are not
(yet) in the database<remote>`
- **0 hack** required for :ref:`admin integration<quick-admin>`, just use a
@@ -49,6 +51,7 @@ Full documentation
navigation
forms
template
+ charfield
generic
remote
dependant

0 comments on commit fc79028

Please sign in to comment.
Something went wrong with that request. Please try again.