{ "info": { "author": "Jordan Nath", "author_email": "jordannh@sent.com", "bugtrack_url": null, "classifiers": [], "description": "# Purpose of Field Tree\n\nThis plugin is a wrapper for dynamic form rendering, and works even for users\nthat block scripts (gasp! I know!).\n\nThe most common form of the \"I really need JavaScript for this\" attitude is\ndynamic form rendering, where one select box renders another select box and so\non. One example you may have encountered is the obligitory Country-State-City\nselect box.\n\nThis plugin makes it easy to render a form based on input. Plus, it works\nwithout JavaScript! The plugin will automatically detect if JasvaScript is\nturned off, and render a submit button for continuing.\n\nConsequently, the form is resubmitted whether someone is using Javascript or no\nJavascript. **Any developer using this plugin must plan accordingly.**\n\n# Requirements\n\nSince this is a Django plugin, obviously django must be installed. Besides that,\nyou must have jquery installed and linked within the page that uses FieldTree\nin order to use the javascript functionality.\n\n# Getting Started\n\n\n1. You can install moreforms by typing\n\n $ pip install django-moreforms\n \nin the command line.\n\n2. Ensure that 'moreforms' is listed in INSTALLED_APPS in `settings.py`:\n\n INSTALLED_APPS = (\n ...\n 'moreforms',\n ...\n )\n \n3. Finally, to construct the FieldTree, do the following:\n\n from django import forms\n from moreforms import FieldTree as T, FieldLeaf as L\n \n class MyForm(forms.Form):\n name = forms.CharField(...)\n age = forms.IntegerField(...)\n ...\n \n # Every form with a FieldTree must have a delete_field method. I'll\n # explain later...\n def delete_field(self, name):\n del self.field[name]\n \n # Make sure to override the __init__ method.\n def __init__(self, *args, **kwargs):\n \n request = kwargs.pop('request', None) # Don't add request as an\n # argument itself.\n \n super(MyForm, self).__init__(*args, **kwargs)\n \n tree = T(request, self,\n L(None, 'name', children=(\n L('.*', 'age'),\n ))\n )\n \n tree.vacuum()\n \n4. Within the django template you need to load the template tags:\n\n {% load moreforms %}\n \n {{ form.as_p }} {% auto_submit %}\n \n`auto_submit` will render both the javascript and the non-script portions\nof the FieldTree.\n \n## What the code does.\n\n`FieldTree` is, essentially a tree, where each leaf has a regular expression,\na name of a field, and (optionally) any children, which--in themselves--are\nleaves.\n\nThe **regular expression** is what is expected from the parent's field. In\nthe above example, we want to render the 'age' field if the value of\n'name' is posted. Note that the top-most leaf ('name') has `None` as the\nregexp. This is becaue **the top-most leaf must have a None regexp.**\n\n## That's it!\n\nNow, just create the form in the view, taking care to pass in `request` as well.\n\n def my_view(request):\n \n form = MyForm(request)\n return render(request, 'some_page.html', {'form' : form})\n \n# A Few Notes\n\n## `delete_field` function.\n\nSince a FieldTree cannot delete the fields on the passed-in form directly,\nthey must be deleted manually from the form. Basically you just need the lines\nprovided in the example.\n\n## Default input value\n\nIf you want a default input value (e.g. automatically fill in the submitted\n`name`), do the following in the form:\n\n class MyForm(forms.Form):\n ...\n def __init__(self, *args, **kwargs):\n ...\n super(...).__init__(...)\n ...\n self.initial = {'name' : ... }\n \nThis is standard for django forms, but just thought you'd like to know.\n\n## You might want a note...\n\nYou might want a note preceeding the form to explain how the TreeField works.\n", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "django-moreforms", "package_url": "https://pypi.org/project/django-moreforms/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-moreforms/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/django-moreforms/1.2/", "requires_dist": null, "requires_python": null, "summary": "Contains helpful fields for Django, such as a FieldTree (a simple way to get a field chain) and date-related fields.", "version": "1.2" }, "last_serial": 911169, "releases": { "1.0": [ { "comment_text": "built for Linux-3.11.0-12-generic-x86_64-with-glibc2.7", "digests": { "md5": "cc94a705531247e5bb8319ff4ffe3d92", "sha256": "339d67da599635fe0ddde5f9e44a4a293a54ba98f79b0cf5fcbca46615457169" }, "downloads": -1, "filename": "django-moreforms-1.0.linux-x86_64.tar.gz", "has_sig": false, "md5_digest": "cc94a705531247e5bb8319ff4ffe3d92", "packagetype": "bdist_dumb", "python_version": "any", "requires_python": null, "size": 12334, "upload_time": "2013-11-02T22:25:15", "url": "https://files.pythonhosted.org/packages/61/d4/1b60b856c0e8d08429ca5db0003de37a841b74824f509a29e338e6f3809f/django-moreforms-1.0.linux-x86_64.tar.gz" }, { "comment_text": "", "digests": { "md5": "ab235df853afb0569cdf79083cd3cd80", "sha256": "d7784df309bc982a18f949053cfda97965315d5bd667be3b25218f3fe029ce0e" }, "downloads": -1, "filename": "django-moreforms-1.0.tar.gz", "has_sig": false, "md5_digest": "ab235df853afb0569cdf79083cd3cd80", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7342, "upload_time": "2013-11-02T22:25:06", "url": "https://files.pythonhosted.org/packages/dd/60/e16f2d95b4b900622335e231d8e9abe2d2e1faf103512a0ecb697e5b0eb3/django-moreforms-1.0.tar.gz" } ], "1.1": [ { "comment_text": "built for Linux-3.11.0-12-generic-x86_64-with-glibc2.7", "digests": { "md5": "a9d62437ac9d786e43c91415a0666c1c", "sha256": "4bdcc4d1deca03fbf33d35f1a97f34a297c5c4eecfcfa155026cea374244964f" }, "downloads": -1, "filename": "django-moreforms-1.1.linux-x86_64.tar.gz", "has_sig": true, "md5_digest": "a9d62437ac9d786e43c91415a0666c1c", "packagetype": "bdist_dumb", "python_version": "any", "requires_python": null, "size": 12342, "upload_time": "2013-11-02T22:26:29", "url": "https://files.pythonhosted.org/packages/62/18/3a231bf2992f1db9d25e1149707a4ff570241a575a09e723a49cf807df02/django-moreforms-1.1.linux-x86_64.tar.gz" }, { "comment_text": "", "digests": { "md5": "17a4a5d512fd45ea013c997db156f07d", "sha256": "acc5cf1769f718b38a6c742a04064f77106f72e58960174068a9e26ac89dba90" }, "downloads": -1, "filename": "django-moreforms-1.1.tar.gz", "has_sig": true, "md5_digest": "17a4a5d512fd45ea013c997db156f07d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7345, "upload_time": "2013-11-02T22:26:27", "url": "https://files.pythonhosted.org/packages/e9/a5/1107e3e2a3ef33bee12217633ddf2fe1a2bb1809ef8038a961a37b75510b/django-moreforms-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "436046101c6cd4b7bd2e6ffdf159563f", "sha256": "b0f041a10b41a19a08930de66965f71ec5590be2bf756ac46cc597a2b86bba44" }, "downloads": -1, "filename": "django-moreforms-1.2.tar.gz", "has_sig": false, "md5_digest": "436046101c6cd4b7bd2e6ffdf159563f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9037, "upload_time": "2013-11-04T22:18:52", "url": "https://files.pythonhosted.org/packages/97/b2/6e686ccbb8d1d4d7d97f927de30c5aa9a0038e14644e97da6ac72d590b68/django-moreforms-1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "436046101c6cd4b7bd2e6ffdf159563f", "sha256": "b0f041a10b41a19a08930de66965f71ec5590be2bf756ac46cc597a2b86bba44" }, "downloads": -1, "filename": "django-moreforms-1.2.tar.gz", "has_sig": false, "md5_digest": "436046101c6cd4b7bd2e6ffdf159563f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9037, "upload_time": "2013-11-04T22:18:52", "url": "https://files.pythonhosted.org/packages/97/b2/6e686ccbb8d1d4d7d97f927de30c5aa9a0038e14644e97da6ac72d590b68/django-moreforms-1.2.tar.gz" } ] }