{ "info": { "author": "Simon Hanna", "author_email": "simhnna@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# django-widgets-improved\n\n[![Build Status](https://travis-ci.org/simhnna/django-widgets-improved.svg?branch=master)](https://travis-ci.org/simhnna/django-widgets-improved)\n\nTweak the form field rendering in templates, not in python-level\nform definitions. Altering CSS classes and HTML attributes is supported.\n\nThat should be enough for designers to customize field presentation (using\nCSS and unobtrusive javascript) without touching python code.\n\n\nThis project is a fork of the unmaintained [django-widget-tweaks](https://github.com/jazzband/django-widget-tweaks) repository.\nIt is a drop-in replacement. Just unintall django-widget-tweaks and install this instead.\n\n## Installation\n\nYou can get Django Widget Tweaks by using pip::\n\n $ pip install django-widgets-improved\n\nTo enable `widget_tweaks` in your project you need to add it to `INSTALLED_APPS` in your projects \n`settings.py` file:\n\n```\n INSTALLED_APPS = [\n ...\n 'widget_tweaks',\n ...\n ]\n```\n\n## Usage\n\nThis app provides two sets of tools that may be used together or standalone:\n\n1. a `render_field` template tag for customizing form fields by using an\n HTML-like syntax.\n2. several template filters for customizing form field HTML attributes and CSS\n classes\n\nThe `render_field` tag should be easier to use and should make form field\ncustomizations much easier for designers and front-end developers.\n\nThe template filters are more powerful than the `render_field` tag, but they\nuse a more complex and less HTML-like syntax.\n\n### render_field\n\nThis is a template tag that can be used as an alternative to aforementioned\nfilters. This template tag renders a field using a syntax similar to plain\nHTML attributes.\n\nExample:\n```\n {% load widget_tweaks %}\n\n \n {% render_field form.search_query type=\"search\" %}\n\n \n {% render_field form.text rows=\"20\" cols=\"20\" title=\"Hello, world!\" %}\n\n \n {% render_field form.title class+=\"css_class_1 css_class_2\" %}\n\n \n {% render_field form.text placeholder=form.text.label %}\n```\nFor fields rendered with `{% render_field %}` tag it is possible\nto set error class and required fields class by using\n`WIDGET_ERROR_CLASS` and `WIDGET_REQUIRED_CLASS` template variables:\n```\n {% with WIDGET_ERROR_CLASS='my_error' WIDGET_REQUIRED_CLASS='my_required' %}\n {% render_field form.field1 %}\n {% render_field form.field2 %}\n {% render_field form.field3 %}\n {% endwith %}\n```\nYou can be creative with these variables: e.g. a context processor could\nset a default CSS error class on all fields rendered by\n`{% render_field %}`.\n\n\n### attr\nAdds or replaces any single html atribute for the form field.\n\nExamples:\n```\n {% load widget_tweaks %}\n\n \n {{ form.search_query|attr:\"type:search\" }}\n\n \n {{ form.text|attr:\"rows:20\"|attr:\"cols:20\"|attr:\"title:Hello, world!\" }}\n\n \n {{ form.search_query|attr:\"autofocus\" }}\n```\n\n### add_class\n\nAdds CSS class to field element. Split classes by whitespace in order to add\nseveral classes at once.\n\nExample:\n```\n {% load widget_tweaks %}\n\n \n {{ form.title|add_class:\"css_class_1 css_class_2\" }}\n```\n\n### set_data\n\nSets HTML5 data attribute ( http://ejohn.org/blog/html-5-data-attributes/ ).\nUseful for unobtrusive javascript. It is just a shortcut for 'attr' filter\nthat prepends attribute names with 'data-' string.\n\nExample:\n```\n {% load widget_tweaks %}\n\n \n {{ form.title|set_data:\"filters:OverText\" }}\n```\n\n### append_attr\n\nAppends atribute value with extra data.\n\nExample:\n```\n {% load widget_tweaks %}\n\n \n {{ form.title|append_attr:\"class:css_class_1 css_class_2\" }}\n```\n'add_class' filter is just a shortcut for 'append_attr' filter that\nadds values to the 'class' attribute.\n\n### add_error_class\n\nThe same as 'add_class' but adds css class only if validation failed for\nthe field (field.errors is not empty).\n\nExample:\n```\n {% load widget_tweaks %}\n\n \n {{ form.title|add_error_class:\"error-border\" }}\n```\n\n### add_error_attr\n\nThe same as 'attr' but sets an attribute only if validation failed for\nthe field (field.errors is not empty). This can be useful when dealing\nwith accessibility:\n```\n {% load widget_tweaks %}\n\n \n {{ form.title|add_error_attr:\"aria-invalid:true\" }}\n```\n\n### field_type and widget_type\n\n`'field_type'` and `'widget_type'` are template filters that return\nfield class name and field widget class name (in lower case).\n\nExample:\n```\n {% load widget_tweaks %}\n\n
\n {{ field }}\n
\n```\nOutput:\n```\n
\n \n
\n```\n## Filter chaining\n\nThe order django-widget-tweaks filters apply may seem counter-intuitive\n(leftmost filter wins):\n```\n {{ form.simple|attr:\"foo:bar\"|attr:\"foo:baz\" }}\n```\nreturns:\n```\n \n```\nIt is not a bug, it is a feature that enables creating reusable templates\nwith overridable defaults.\n\nReusable field template example:\n```\n {# inc/field.html #}\n {% load widget_tweaks %}\n
{{ field|attr:\"foo:default_foo\" }}
\n```\nExample usage:\n```\n {# my_template.html #}\n {% load widget_tweaks %}\n
{% csrf_token %}\n {% include \"inc/field.html\" with field=form.title %}\n {% include \"inc/field.html\" with field=form.description|attr:\"foo:non_default_foo\" %}\n
\n```\nWith 'rightmost filter wins' rule it wouldn't be possible to override\n`|attr:\"foo:default_foo\"` in main template.\n\n## Contributing\n\nIf you've found a bug, implemented a feature or have a suggestion,\ndo not hesitate to contact me, fire an issue or send a pull request.\n\n* Source code: https://github.com/simhnna/django-widgets-improved/\n* Bug tracker: https://github.com/simhnna/django-widgets-improved/issues\n\n## Testing\n\nMake sure you have [tox](http://tox.testrun.org/) installed, then type `tox`\nfrom anywhere within the repository.\n\n\n\n# Changelog\n\n## 1.4.1 (2015-06-29)\n------------------\n\n* fixed a regression in django-widget-tweaks v1.4\n (the field is no longer deep copied).\n\n## 1.4 (2015-06-27)\n\n* Django 1.7, 1.8 and 1.9 support;\n* setup.py is switched to setuptools;\n* testing improvements;\n* Python 3.4 support is added;\n* Python 2.5 is not longer supported;\n* bitbucket repository is no longer supported (development is moved to github).\n\n## 1.3 (2013-04-05)\n\n* added support for ``WIDGET_ERROR_CLASS`` and ``WIDGET_REQUIRED_CLASS``\n template variables that affect ``{% render_field %}``.\n\n## 1.2 (2013-03-23)\n\n* new ``add_error_attr`` template filter;\n* testing improvements.\n\n## 1.1.2 (2012-06-06)\n\n* support for template variables is added to ``render_field`` tag;\n* new ``field_type`` and ``widget_type`` filters.\n\n## 1.1.1 (2012-03-22)\n\n* some issues with ``render_field`` tag are fixed.\n\n## 1.1 (2012-03-22)\n\n* ``render_field`` template tag.\n\n## 1.0 (2012-02-06)\n\n* filters return empty strings instead of raising exceptions if field is missing;\n* test running improvements;\n* python 3 support;\n* undocumented 'behave' filter is removed.\n\n## 0.3 (2011-03-04)\n\n* ``add_error_class`` filter.\n\n## 0.2.1 (2011-02-03)\n\n* Attributes customized in widgets are preserved;\n* no more extra whitespaces;\n* tests;\n\n## 0.1 (2011-01-12)\n\nInitial release.\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/simhnna/django-widgets-improved", "keywords": "", "license": "MIT license", "maintainer": "", "maintainer_email": "", "name": "django-widgets-improved", "package_url": "https://pypi.org/project/django-widgets-improved/", "platform": "", "project_url": "https://pypi.org/project/django-widgets-improved/", "project_urls": { "Homepage": "https://github.com/simhnna/django-widgets-improved" }, "release_url": "https://pypi.org/project/django-widgets-improved/1.5.0/", "requires_dist": null, "requires_python": "", "summary": "Tweak the form field rendering in templates, not in python-level form definitions.", "version": "1.5.0" }, "last_serial": 3478303, "releases": { "1.5.0": [ { "comment_text": "", "digests": { "md5": "3cfc69a8e12db53229d3ca7c2ddf5eb9", "sha256": "db66019bfe5bb40e552db2109dab3854c65f1bf7759eef12b2eb574014f9539f" }, "downloads": -1, "filename": "django_widgets_improved-1.5.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3cfc69a8e12db53229d3ca7c2ddf5eb9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 13100, "upload_time": "2018-01-10T17:33:47", "url": "https://files.pythonhosted.org/packages/1c/75/83b607b48aa774218379a3cbb780c402fc4cd8375f77afef9564370c1c79/django_widgets_improved-1.5.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0180a349d0a3914db2ba13adaa83f77a", "sha256": "7c9e8e931e251e3308b1eddc1b8e8e7312f3bef47e01924835f7ee6ca4c15da1" }, "downloads": -1, "filename": "django-widgets-improved-1.5.0.tar.gz", "has_sig": false, "md5_digest": "0180a349d0a3914db2ba13adaa83f77a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9729, "upload_time": "2018-01-10T17:33:48", "url": "https://files.pythonhosted.org/packages/c0/2d/94e6d6b5a613458ee7b464ad8c6fb219558fd4eef80246f23e1d59762a61/django-widgets-improved-1.5.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3cfc69a8e12db53229d3ca7c2ddf5eb9", "sha256": "db66019bfe5bb40e552db2109dab3854c65f1bf7759eef12b2eb574014f9539f" }, "downloads": -1, "filename": "django_widgets_improved-1.5.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "3cfc69a8e12db53229d3ca7c2ddf5eb9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 13100, "upload_time": "2018-01-10T17:33:47", "url": "https://files.pythonhosted.org/packages/1c/75/83b607b48aa774218379a3cbb780c402fc4cd8375f77afef9564370c1c79/django_widgets_improved-1.5.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0180a349d0a3914db2ba13adaa83f77a", "sha256": "7c9e8e931e251e3308b1eddc1b8e8e7312f3bef47e01924835f7ee6ca4c15da1" }, "downloads": -1, "filename": "django-widgets-improved-1.5.0.tar.gz", "has_sig": false, "md5_digest": "0180a349d0a3914db2ba13adaa83f77a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9729, "upload_time": "2018-01-10T17:33:48", "url": "https://files.pythonhosted.org/packages/c0/2d/94e6d6b5a613458ee7b464ad8c6fb219558fd4eef80246f23e1d59762a61/django-widgets-improved-1.5.0.tar.gz" } ] }