m3-django-composite-foreignkey


Namem3-django-composite-foreignkey JSON
Version 1.0.4 PyPI version JSON
download
home_pagehttps://stash.bars-open.ru/projects/M3/repos/m3-django-composite-foreignkey
Summarycomposite foreignkey support for django
upload_time2024-11-14 08:50:07
maintainerNone
docs_urlNone
authorBARS Group
requires_pythonNone
licenseGNU GENERAL PUBLIC LICENSE
keywords django composite foreignkey
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ==============================
m3-django-composite-foreignkey
==============================

Данный пакет - это fork https://github.com/michael-k/django-composite-foreignkey/tree/django32-python39. Создан по причине того, что оригинальный 
https://github.com/onysos/django-composite-foreignkey не принимает PR https://github.com/onysos/django-composite-foreignkey/pull/18 длительное время.
Возможно, первоначальный дистрибутив заброшен и больше не используется. Информация ниже является текстом оригинала и оставлена без изменений.


allow to create a django foreignkey that don't link with pk of other model, but with multi column matching local model columns or fixed values.


.. image:: https://img.shields.io/travis/onysos/django-composite-foreignkey/master.svg
    :target: https://travis-ci.org/onysos/django-composite-foreignkey

.. image:: https://readthedocs.org/projects/django-composite-foreignkey/badge/?version=latest
    :target: http://django-composite-foreignkey.readthedocs.org/en/latest/

.. image:: https://img.shields.io/coveralls/onysos/django-composite-foreignkey/master.svg
  :target: https://coveralls.io/r/onysos/django-composite-foreignkey?branch=master

.. image:: https://img.shields.io/pypi/v/django-composite-foreignkey.svg
    :target: https://pypi.python.org/pypi/django-composite-foreignkey
    :alt: Latest PyPI version

.. image:: https://img.shields.io/pypi/dm/django-composite-foreignkey.svg
    :target: https://pypi.python.org/pypi/django-composite-foreignkey
    :alt: Number of PyPI downloads per month


some databases have a composite Primary Key, leading to impossiblity for a django foreign key to be used.

today, Django don't support Composite Primary Key `see ticket <https://code.djangoproject.com/wiki/MultipleColumnPrimaryKeys>`_ and ForeignKey don't support multicolumn.
but fortunaly, the base class of ForeignKey support it well, so this lib just add a little wrapper around ForeignObject to make it more usefull.
the real add of this implementation is that is support the customisation of the link with Raw values.

this implementation of CompositeForeignKey skip the complexity of Composite Primary Key by forcing the providing of the corresponding column of the other model, not forcefully a PrimaryKey.

Installation
------------

1. Install using pip:

   ``pip install django-composite-foreignkey``

2. Alternatively, you can install download or clone this repo and call

    ``pip install -e .``.



Example
-------


you have this model

.. code:: python

    class Customer(models.Model):

        company = models.IntegerField()
        customer_id = models.IntegerField()
        name = models.CharField(max_length=255)
        address = CompositeForeignKey(Address, on_delete=CASCADE, to_fields={
            "tiers_id": "customer_id",
            "company": LocalFieldValue("company"),
            "type_tiers": RawFieldValue("C")
        })

        class Meta(object):
            unique_together = [
                ("company", "customer_id"),
            ]


    class Contact(models.Model):
        company_code = models.IntegerField()
        customer_code = models.IntegerField()
        surname = models.CharField(max_length=255)
        # virtual field
        customer = CompositeForeignKey(Customer, on_delete=CASCADE, related_name='contacts', to_fields={
            "customer_id": "customer_code",
            "company": "company_code"
        })


you can use Contact.customer like any ForeignKey, but behinde the scene, it will query the Customer Table using company and customer id's.


Documentation
-------------

The full documentation is at http://django-composite-foreignkey.readthedocs.org/en/latest/.


Requirements
------------

- Python 2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9
- Django 1.11, 2.0, 2.1, 2.2, 3.1, 3.2

Contributions and pull requests for other Django and Python versions are welcome.


Bugs and requests
-----------------

If you have found a bug or if you have a request for additional functionality, please use the issue tracker on GitHub.

https://github.com/onysos/django-composite-foreignkey/issues


License
-------

You can use this under GPLv3.

Author
------

Original author & Development lead: `Darius BERNARD <https://github.com/ornoone>`_.


Thanks
------

Thanks to django for this amazing framework. And thanks to django-bootstrap3 to the structure of the apps.

            

Raw data

            {
    "_id": null,
    "home_page": "https://stash.bars-open.ru/projects/M3/repos/m3-django-composite-foreignkey",
    "name": "m3-django-composite-foreignkey",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "django composite foreignkey",
    "author": "BARS Group",
    "author_email": "contact@xornot.fr",
    "download_url": "https://files.pythonhosted.org/packages/21/94/1de622d9b7dd17b68971d2855cb4e8b10b36278eb0f894a573c345e2a021/m3_django_composite_foreignkey-1.0.4.tar.gz",
    "platform": null,
    "description": "==============================\nm3-django-composite-foreignkey\n==============================\n\n\u0414\u0430\u043d\u043d\u044b\u0439 \u043f\u0430\u043a\u0435\u0442 - \u044d\u0442\u043e fork https://github.com/michael-k/django-composite-foreignkey/tree/django32-python39. \u0421\u043e\u0437\u0434\u0430\u043d \u043f\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \nhttps://github.com/onysos/django-composite-foreignkey \u043d\u0435 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 PR https://github.com/onysos/django-composite-foreignkey/pull/18 \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.\n\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u0434\u0438\u0441\u0442\u0440\u0438\u0431\u0443\u0442\u0438\u0432 \u0437\u0430\u0431\u0440\u043e\u0448\u0435\u043d \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f. \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043d\u0438\u0436\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u0430 \u0438 \u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0430 \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.\n\n\nallow to create a django foreignkey that don't link with pk of other model, but with multi column matching local model columns or fixed values.\n\n\n.. image:: https://img.shields.io/travis/onysos/django-composite-foreignkey/master.svg\n    :target: https://travis-ci.org/onysos/django-composite-foreignkey\n\n.. image:: https://readthedocs.org/projects/django-composite-foreignkey/badge/?version=latest\n    :target: http://django-composite-foreignkey.readthedocs.org/en/latest/\n\n.. image:: https://img.shields.io/coveralls/onysos/django-composite-foreignkey/master.svg\n  :target: https://coveralls.io/r/onysos/django-composite-foreignkey?branch=master\n\n.. image:: https://img.shields.io/pypi/v/django-composite-foreignkey.svg\n    :target: https://pypi.python.org/pypi/django-composite-foreignkey\n    :alt: Latest PyPI version\n\n.. image:: https://img.shields.io/pypi/dm/django-composite-foreignkey.svg\n    :target: https://pypi.python.org/pypi/django-composite-foreignkey\n    :alt: Number of PyPI downloads per month\n\n\nsome databases have a composite Primary Key, leading to impossiblity for a django foreign key to be used.\n\ntoday, Django don't support Composite Primary Key `see ticket <https://code.djangoproject.com/wiki/MultipleColumnPrimaryKeys>`_ and ForeignKey don't support multicolumn.\nbut fortunaly, the base class of ForeignKey support it well, so this lib just add a little wrapper around ForeignObject to make it more usefull.\nthe real add of this implementation is that is support the customisation of the link with Raw values.\n\nthis implementation of CompositeForeignKey skip the complexity of Composite Primary Key by forcing the providing of the corresponding column of the other model, not forcefully a PrimaryKey.\n\nInstallation\n------------\n\n1. Install using pip:\n\n   ``pip install django-composite-foreignkey``\n\n2. Alternatively, you can install download or clone this repo and call\n\n    ``pip install -e .``.\n\n\n\nExample\n-------\n\n\nyou have this model\n\n.. code:: python\n\n    class Customer(models.Model):\n\n        company = models.IntegerField()\n        customer_id = models.IntegerField()\n        name = models.CharField(max_length=255)\n        address = CompositeForeignKey(Address, on_delete=CASCADE, to_fields={\n            \"tiers_id\": \"customer_id\",\n            \"company\": LocalFieldValue(\"company\"),\n            \"type_tiers\": RawFieldValue(\"C\")\n        })\n\n        class Meta(object):\n            unique_together = [\n                (\"company\", \"customer_id\"),\n            ]\n\n\n    class Contact(models.Model):\n        company_code = models.IntegerField()\n        customer_code = models.IntegerField()\n        surname = models.CharField(max_length=255)\n        # virtual field\n        customer = CompositeForeignKey(Customer, on_delete=CASCADE, related_name='contacts', to_fields={\n            \"customer_id\": \"customer_code\",\n            \"company\": \"company_code\"\n        })\n\n\nyou can use Contact.customer like any ForeignKey, but behinde the scene, it will query the Customer Table using company and customer id's.\n\n\nDocumentation\n-------------\n\nThe full documentation is at http://django-composite-foreignkey.readthedocs.org/en/latest/.\n\n\nRequirements\n------------\n\n- Python 2.7, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9\n- Django 1.11, 2.0, 2.1, 2.2, 3.1, 3.2\n\nContributions and pull requests for other Django and Python versions are welcome.\n\n\nBugs and requests\n-----------------\n\nIf you have found a bug or if you have a request for additional functionality, please use the issue tracker on GitHub.\n\nhttps://github.com/onysos/django-composite-foreignkey/issues\n\n\nLicense\n-------\n\nYou can use this under GPLv3.\n\nAuthor\n------\n\nOriginal author & Development lead: `Darius BERNARD <https://github.com/ornoone>`_.\n\n\nThanks\n------\n\nThanks to django for this amazing framework. And thanks to django-bootstrap3 to the structure of the apps.\n",
    "bugtrack_url": null,
    "license": "GNU GENERAL PUBLIC LICENSE",
    "summary": "composite foreignkey support for django",
    "version": "1.0.4",
    "project_urls": {
        "Homepage": "https://stash.bars-open.ru/projects/M3/repos/m3-django-composite-foreignkey"
    },
    "split_keywords": [
        "django",
        "composite",
        "foreignkey"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3cde756b623301ee79b7a021f82f2c0be6efdc11a02b583409b1b424bc8a5ba2",
                "md5": "15a74bfac6c9afb003b5d85aea3e8f75",
                "sha256": "5019e67edefee12e1d27197a202abb71f1d4715bfd6997eefe35a2b050d2049f"
            },
            "downloads": -1,
            "filename": "m3_django_composite_foreignkey-1.0.4-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "15a74bfac6c9afb003b5d85aea3e8f75",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 22612,
            "upload_time": "2024-11-14T08:50:05",
            "upload_time_iso_8601": "2024-11-14T08:50:05.514978Z",
            "url": "https://files.pythonhosted.org/packages/3c/de/756b623301ee79b7a021f82f2c0be6efdc11a02b583409b1b424bc8a5ba2/m3_django_composite_foreignkey-1.0.4-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "21941de622d9b7dd17b68971d2855cb4e8b10b36278eb0f894a573c345e2a021",
                "md5": "1f43a186b9c7602896d9d1e61ab20bb7",
                "sha256": "cbe497545448e2106125c23a7b6d05bf11d2156ff17a3600d4be89e98ad9e0cd"
            },
            "downloads": -1,
            "filename": "m3_django_composite_foreignkey-1.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "1f43a186b9c7602896d9d1e61ab20bb7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 25403,
            "upload_time": "2024-11-14T08:50:07",
            "upload_time_iso_8601": "2024-11-14T08:50:07.437069Z",
            "url": "https://files.pythonhosted.org/packages/21/94/1de622d9b7dd17b68971d2855cb4e8b10b36278eb0f894a573c345e2a021/m3_django_composite_foreignkey-1.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-14 08:50:07",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "m3-django-composite-foreignkey"
}
        
Elapsed time: 1.35719s