{ "info": { "author": "Antoine Humeau", "author_email": "humeau.antoine@gmail.com", "bugtrack_url": null, "classifiers": [ "Framework :: Django", "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3" ], "description": "# Django multi field form validation\n\n\n\nProvides a Django form mixin that allows declaring validation methods \n(similar to the Django `Form.clean_()` methods) working on multiple \nfields, allowing less boilerplate code in `Form.clean()`.\n\n\n*Tested on Django 1.7, 1.8 and Python 2.7, 3.2, 3.3, 3.4*\n\n\n## Installation\n\n`pip install django_multifield_clean`\n\n## Usage\n\nMake your form inherit from the `multifieldclean.forms.MultiFieldCleanFormMixin` mixin. Note that the mixin must come **before** the Django form class.\n\n\nDeclare methods starting with `MULTIFIELD_CLEAN_METHOD_PREFIX` (default is `multi_clean`) which arguments are named after field names.\n\nThose methods will be called during the form validation process, after `Form.clean()`, with the field values their arguments are named after as parameters.\n\nIf an argument has no default value, the validation method is called only if the field it is refering to has a value.\n\nExample:\n\n\n from django import forms\n from django.core.exceptions import Validationerror\n\n from multifieldclean.forms import MultiFieldCleanFormMixin\n \n \n # The mixin must be placed before 'forms.Form'\n # so it can override its methods.\n class HolidaysForm(MultiFieldCleanFormMixin, forms.Form):\n start = forms.IntegerField()\n end = forms.IntegerField()\n \n # Any method starting with \"multiclean\" will be\n # interpreted as a multi field validation method.\n # The method will only be called only if 'start' and\n # 'end' have values.\n def multiclean_holidays_end_after_they_start(self, start, end):\n if start > end:\n self.add_error('end', \n ValidationError('These holidays end before they even start!'))\n \n \n \n\n \n \n \n### Configuration\n\n* `MULTIFIELD_CLEAN_METHOD_PREFIX`: modify the prefix used to detect validation methods, default is `multiclean`.\n\n## Why?\n\nI often found myself writing a lot of boilerplate code when overriding the `Form.clean()` method, for example:\n\n def clean(self):\n start = self.cleaned_data.get('start')\n end = self.cleaned_data.get('end')\n if start and end:\n if start > end:\n # etc...\n \nIt is boring to write and harder to read. This package tries to provide a solution to this issue.\n\n\n## Contributing\n\nPull requests are welcome.\n\nRunnig the tests:\n\n* To run the full suite, use `tox`.\n* To run them for your current environment:\n * Install test requirements `pip install -r test-requirements.txt`\n * Install the targeted Django version.\n * Run `py.test`\n * Use `py.test --cov multifieldclean` to get the coverage report.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "TODO", "keywords": null, "license": "TODO", "maintainer": null, "maintainer_email": null, "name": "django_multifield_clean", "package_url": "https://pypi.org/project/django_multifield_clean/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django_multifield_clean/", "project_urls": { "Download": "UNKNOWN", "Homepage": "TODO" }, "release_url": "https://pypi.org/project/django_multifield_clean/0.0.1/", "requires_dist": null, "requires_python": null, "summary": "TODO", "version": "0.0.1" }, "last_serial": 1537475, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "95f222be65296c3b0d2621c210b85788", "sha256": "ba818f3ce5786108a162beb15d15c9844925132111f3af3c10819d283a74f426" }, "downloads": -1, "filename": "django_multifield_clean-0.0.1.tar.gz", "has_sig": false, "md5_digest": "95f222be65296c3b0d2621c210b85788", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4891, "upload_time": "2015-05-07T16:03:52", "url": "https://files.pythonhosted.org/packages/5d/3a/3cf027bb6d24234ffbb247085da6241d0417154ea2ce760f2aebf2d8fe07/django_multifield_clean-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "95f222be65296c3b0d2621c210b85788", "sha256": "ba818f3ce5786108a162beb15d15c9844925132111f3af3c10819d283a74f426" }, "downloads": -1, "filename": "django_multifield_clean-0.0.1.tar.gz", "has_sig": false, "md5_digest": "95f222be65296c3b0d2621c210b85788", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4891, "upload_time": "2015-05-07T16:03:52", "url": "https://files.pythonhosted.org/packages/5d/3a/3cf027bb6d24234ffbb247085da6241d0417154ea2ce760f2aebf2d8fe07/django_multifield_clean-0.0.1.tar.gz" } ] }