{ "info": { "author": "F\u00e1bio Mac\u00eado Mendes", "author_email": "fabiomacedomendes@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License (GPL)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Libraries" ], "description": "``django-model-reference`` defines a simple :cls:`model_reference.Reference`\nmodel that hold named references to specific instances of any Django model.\n\nUsage\n=====\n\nReferences are controlled by the :func:`register()` and :func:`load` functions of\nthe ``model_reference`` module. These function are also mirrored by the\ncorresponding methods in the ``Reference.objects`` manager. To register a\nreference, simply pass the object and either a unique name or a unique suffix::\n\n from model_reference import register, load\n from django.contrib.auth.models import User\n\n # Fetch some objects\n john = User.objects.get(username='john')\n ringo = User.objects.get(username='ringo')\n\n # Register references in the database\n register(john, 'favorite beatle')\n register(ringo, suffix='drummer')\n\nThe name for each reference is unique. If the register function is called with\nthe explicit ``suffix`` argument, it will register the instance as\n``.:suffix``, which in our case becomes ``'auth.user:drummer'``.\n\nIn order to retrieve the objects referred by the Reference object, we can use\nthe :func:`load` function::\n\n>>> load('favorite beatle')\n\n>>> load('drummer', model=User)\n\n\nObjects registered with the suffix form of the register function should pass a\nmodel class in order to construct the complete name string. This is equivalent\nas creating the string by hand:\n\n>>> load('auth.user:drummer')\n\n\n\nEmpty references\n================\n\nIf one request a non-existing reference to the load() function, it raises an\n:error:`model_reference.EmptyReferenceError`. Users can register factory\nfunctions to create these objects on-the-fly.\n\nThe default way of registering factory function is via the :func:`model_reference.factory`\ndecorator. It must be called with a reference string (or suffix + model) and\ndecorates a function that return a new instance and is called without arguments::\n\n @factory('drummer', model=User)\n def make_ringo():\n user, created = User.object.get_or_create(\n username=ringo,\n first_name='Richard'\n last_name='Starkley',\n email='ringo@applerecords.co.uk'\n )\n return user\n\nIf a new instance is created, the function is responsible to save it in the\ndatabase", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/fabiommendes/django-model-reference", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "model-reference", "package_url": "https://pypi.org/project/model-reference/", "platform": "any", "project_url": "https://pypi.org/project/model-reference/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/fabiommendes/django-model-reference" }, "release_url": "https://pypi.org/project/model-reference/0.1.1/", "requires_dist": null, "requires_python": null, "summary": "Stores named references to specific instances of any model in the database.", "version": "0.1.1" }, "last_serial": 2354923, "releases": { "0.1.1": [] }, "urls": [] }