{ "info": { "author": "Chang Phui Hock", "author_email": "phuihock@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: GNU Affero General Public License v3", "Operating System :: OS Independent", "Programming Language :: Python :: 2" ], "description": "INTRODUCTION\n============\nThis is a Django utility package to handle zero or more form inputs of the same name.\n\nIt is not uncommon to find a situation where you need to allow zero or more values for the same field. For example:\n\nEnter your favorite colors:\n\n::\n\n 1. [ red ] [+] [-]\n 2. [ purple ] [+] [-]\n 3. [ green ] [+] [-]\n\nAs an alternative to Django's Formset, you can choose to do the following with django-xfield:\n\n::\n\n # forms.py\n class FavColorForm(forms.Form):\n colors = ExpandableField(fields.CharField, min_values=3, max_length=100)\n\n::\n\n # views.py\n def echo_fav_colors(request):\n form = FavColorForm(request.POST)\n if form.is_valid():\n # because 'colors' is an expandable field, it returns a list of all values submitted by the name 'colors'\n colors = self.cleaned_data['colors']\n assert colors == ['red', 'purple', 'green']\n ...\n\ndjango-xfield introduces 2 classes (they are closures in disguise): ``ExpandableField`` and ``ExpandableWidget``, both are factories that return a subclass\nof the class that you provide as the first positional argument. ``ExpandableField`` accepts 2 optional arguments - ``min_values`` and ``max_values`` and pass the\nrest of the arguments, if provided, to the actual field class for initialization. \n\n``min_values``\n the minimum number of values that user must provided, default to 0\n\n``max_values``\n the maximum number of values that user can supply, default to None (**WARNING** not implemented)\n\nFor example, \"colors\" is assigned a subclass of CharField that returns a list with a minimum of 3 items/values in it. \n\nJust like a normal field, you can supply a different widget if the default is not what you want. However, the widget must be an instance of the\nclass that ``ExpandableWidget`` returns (recall that ``ExpandableWidget`` is a closure, not a class). For example:\n\n::\n\n class FavColorForm(forms.Form):\n colors = ExpandableField(fields.CharField, min_values=3, max_length=100, widget=ExpandableWidget(Textarea, min_values=3))\n \n**NOTE** It is necessary to pass the same ``min_values``/``max_values`` if you are supplying a custom ``ExpandableWidget``.\n\nThis simplify the server-side as well as client-side (Javascript) programming. For a list of working examples, please visit http://demo.phuihock.com/xfield/.\nAlternatively, you can also run the demo locally:\n\n::\n\n $ git clone git://github.com/phuihock/django-xfield.git\n $ virtualenv --distribute django-xfield\n $ cd django-xfield\n $ source bin/activate\n $ pip install -r req.txt\n $ python manage.py runserver\n\nThen, go to http://127.0.0.1:8000/\n\nWhat works for me may not work for everyone else. If you find this utility useful and need example of specific use case, I'll be glad to provide some.\nAlso, checkout the demo app.\n\nINSTALLATION\n============\n\n::\n\n $ pip install django-xfield\n\nThis is not a Django app, so you don't have to add it to INSTALLED_APPS.\n\n\nCAVEAT\n======\ndjango-xfield works with simple field types, such as CharField, IntegerField, ChoiceField - that returns a single value. It does **not**\nsupport MultiValueField or any subclass of it. That said, do not use this with SplitDateTimeField or your MultiValueField subclass.\n\n\nBUGS\n====\nLikely. If you find one, please file an issue.\n\n\nTODO\n====\nThis should go to issues, but just for the record, this thing needs tests, a lot of tests.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/phuihock/django-xfield", "keywords": null, "license": "GPLv3", "maintainer": null, "maintainer_email": null, "name": "django-xfield", "package_url": "https://pypi.org/project/django-xfield/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-xfield/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/phuihock/django-xfield" }, "release_url": "https://pypi.org/project/django-xfield/0.1.0/", "requires_dist": null, "requires_python": null, "summary": "A Django utility package to handle zero or more form inputs of the same name.", "version": "0.1.0" }, "last_serial": 791049, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "accbd717604baddc0aa5958c1ad133fc", "sha256": "a0cb286afc32f0399cbaed0029c19375fb906b557e18c51a0983ad1b66dbd659" }, "downloads": -1, "filename": "django-xfield-0.1.0.tar.gz", "has_sig": false, "md5_digest": "accbd717604baddc0aa5958c1ad133fc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4347, "upload_time": "2011-06-25T19:13:29", "url": "https://files.pythonhosted.org/packages/5b/ff/d732a65ac42cdc7d078e96ad27aeaaae5f21746b3686ac594ba83e13ea6d/django-xfield-0.1.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "accbd717604baddc0aa5958c1ad133fc", "sha256": "a0cb286afc32f0399cbaed0029c19375fb906b557e18c51a0983ad1b66dbd659" }, "downloads": -1, "filename": "django-xfield-0.1.0.tar.gz", "has_sig": false, "md5_digest": "accbd717604baddc0aa5958c1ad133fc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4347, "upload_time": "2011-06-25T19:13:29", "url": "https://files.pythonhosted.org/packages/5b/ff/d732a65ac42cdc7d078e96ad27aeaaae5f21746b3686ac594ba83e13ea6d/django-xfield-0.1.0.tar.gz" } ] }