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
51 docs/source/charfield.rst
@@ -0,0 +1,51 @@
+.. _charfield:
+CharField autocompletes
+<>`_ and derivates like `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
+As usual, a working example lives in test_project. in app
+This demonstrates a working usage of TextWidget:
+.. literalinclude:: ../../test_project/charfield_autocomplete/
+ :language: python
+FTR, using the form in the admin is still as easy:
+.. literalinclude:: ../../test_project/charfield_autocomplete/
+ :language: python
+So is registering an Autocomplete for Tag:
+.. literalinclude:: ../../test_project/charfield_autocomplete/
+ :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
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
+- **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
+ charfield

0 comments on commit fc79028

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