{ "info": { "author": "Thiago Nascimento", "author_email": "thiagocampostn@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "=====================\nDjango Foreign Fields\n=====================\nDjango Foreign Fields is a Django app that offers two new form fields that help handling foreign relationships in a easier way.\n\nQuick start\n-----------\n.. code:: bash\n\n $ pip install django-foreign-fields\n\nOptional\n^^^^^^^^\nIf it's desired to test the package fields, it's necessary to install it on the project settings:\n\n1. Add \"django-foreign-fields\" to your INSTALLED_APPS setting like this::\n\n INSTALLED_APPS = [\n ...\n 'django-foreign-fields',\n ]\n\n2. Run `python manage.py test django-foreign-fields` to test the foreign fields.\n\nUsage\n-----\nDjango-foreign-fields adds two new form fields ``ForeignField`` and ``TextAreaToManyField``.\n\nFields\n^^^^^^\nBoth form fields need two new arguments: ``to`` and ``selector``.\n\n* ``to``: the `target` model of the relationship. Declaring the `target` model as the first parameter will automatically be detected as the `to` argument.\n\n* ``selector``: the model field where the given value will be searched on.\n\nForeignField\n\"\"\"\"\"\"\"\"\"\"\"\"\nReceives data and searches for an object in database that has that unique value on the given field. The object is stored as a ``ForeignKey``.\n\nTextAreaToManyField\n\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\nBreaks all lines in a ``Textarea`` and use each one to find objects that correspond to each search. Each search must return a unique object, then, all objects are stored in a ``ManyToMany`` relationship.\n\nExamples\n^^^^^^^^\nForeignField\n\"\"\"\"\"\"\"\"\"\"\"\"\nGiven you already have two models, one ``Target`` that holds some information and one ``Referrer`` that will make a foreign relationship to a particular field:\n\n.. code:: python\n\n class Target(models.Model):\n name = models.TextField()\n\n class Referrer(models.Model):\n foreign = models.ForeignKey()\n\nIt will be needed a new form for the ``Referrer``.\n\nThe original form field that holds the foreign key relation on the ``Referrer`` will be substituted for the ``ForeignField``:\n\n.. code:: python\n\n import foreign_fields.ForeignField\n\n class ReferrerForm(forms.ModelForm):\n foreign = foreign_fields.ForeignField(to=Target, selector='name')\n \n class Meta:\n model = Referrer\n\nNow you can use the form on your ``View``. The default widget is ``TextInput``, so when you enter a string in the field and save the form, the ``ForeignField`` will search for a ``Target`` that has the given string in it's ``name`` field that must be unique. If the field is not unique, it will be given a ``ValidationError``.\n\nIt's possible to change the foreign widget into others such as ``NumberInput`` or ``DateInput``.\n\nTextAreaToManyField\n\"\"\"\"\"\"\"\"\"\"\"\"\nGiven you already have two models, one ``Target`` that holds some information and one ``Referrer`` that will make a many to many relationship to a particular field:\n\n.. code:: python\n\n class Target(models.Model):\n name = models.TextField()\n\n class Referrer(models.Model):\n many_to_many = models.ManyToManyField()\n\nIt will be needed a new form for the ``Referrer``.\n\nThe original form field that holds the many to many relation on the ``Referrer`` will be substituted for the ``TextAreaToManyField``:\n\n.. code:: python\n\n import foreign_fields.TextAreaToManyField\n\n class ReferrerForm(forms.ModelForm):\n many_to_many = foreign_fields.TextAreaToManyField(to=Target, selector='name')\n \n class Meta:\n model = Referrer\n\nNow you can use the form on your `View`. The default widget is ``Textarea``, so when you enter a text in the field and save the form, the ``TextAreaToManyField`` will split each line and search for a unique ``Target`` by line that has the given string in it's `name` field. If the field is not unique, it will be given a `ValidationError`.", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ThiagoCTN/django-foreign-fields/", "keywords": "", "license": "MIT License", "maintainer": "", "maintainer_email": "", "name": "django-foreign-fields", "package_url": "https://pypi.org/project/django-foreign-fields/", "platform": "", "project_url": "https://pypi.org/project/django-foreign-fields/", "project_urls": { "Homepage": "https://github.com/ThiagoCTN/django-foreign-fields/" }, "release_url": "https://pypi.org/project/django-foreign-fields/0.1/", "requires_dist": null, "requires_python": "", "summary": "A Django app with new form fields for handling foreign relationships.", "version": "0.1" }, "last_serial": 3832334, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "d8f9dcacc8b0ba3874096be716894990", "sha256": "84f9ee8dc2e20ae4065a30d0459b97180d0951bfcb3436b91cc4c8b49f1c94f6" }, "downloads": -1, "filename": "django-foreign-fields-0.1.tar.gz", "has_sig": false, "md5_digest": "d8f9dcacc8b0ba3874096be716894990", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5535, "upload_time": "2018-05-03T20:29:43", "url": "https://files.pythonhosted.org/packages/3f/fa/c4e544c26de406eb0c306f0d04a8dffce3c1a38ddb0ae46b5eca573583d6/django-foreign-fields-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d8f9dcacc8b0ba3874096be716894990", "sha256": "84f9ee8dc2e20ae4065a30d0459b97180d0951bfcb3436b91cc4c8b49f1c94f6" }, "downloads": -1, "filename": "django-foreign-fields-0.1.tar.gz", "has_sig": false, "md5_digest": "d8f9dcacc8b0ba3874096be716894990", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5535, "upload_time": "2018-05-03T20:29:43", "url": "https://files.pythonhosted.org/packages/3f/fa/c4e544c26de406eb0c306f0d04a8dffce3c1a38ddb0ae46b5eca573583d6/django-foreign-fields-0.1.tar.gz" } ] }