{ "info": { "author": "Michal Dub", "author_email": "michalmam@centrum.cz", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3" ], "description": "Django AppData\n##############\n\nExtandable field and related tools that enable Django apps to extend your\nreusable app.\n\nIMPORTANT NOTE\n**************\n\nThis app is fork of the original `Django appdata `_.\nFork was created because of original application does not work correctly with the latest version of Django and reactions on pull requests are very slow.\nHowever I recommend use the original application if you can.\n\nMotivation\n**********\n\nWhen working with reusable django apps we often found that we needed to add\nsomething extra to the model or form the app provided. Some apps try to solve\nthis by providing a flexible model definition and a pluggable form (see\n`django.contrib.comments` for an exmple of this approach) but even then it\nleads to some duplication of efforts.\n\n`django-appdata` app tries, through `AppDataField`, `MultiForm` and `AppDataModelAdmin`,\nto provide a standardised approach to extending existing apps.\n\nExtending Models\n****************\n\nWhen you have an extendable django app using the `AppDataField`::\n\n from django.db import models\n from app_data import AppDataField\n\n class BlogPost(models.Model):\n text = models.TextField()\n app_data = AppDataField()\n\nyour code can register a namespace on any (or all) `AppDataField` and store\nit's own data there by registering a *container* (subclass of\n`AppDataContainer`). To define the data you use django's form framework::\n\n from django.forms.models import ModelMultipleChoiceField\n from app_data import app_registry, AppDataForm, AppDataContainer\n\n from .models import Tag\n\n class TaggingAppDataForm(AppDataForm):\n public_tags = ModelMultipleChoiceField(Tag.objects.all())\n admin_tags = ModelMultipleChoiceField(Tag.objects.all())\n\n class TaggingAppDataContainer(AppDataContainer):\n form_class = TaggingAppDataForm\n \n def tag_string(self):\n print ', '.join(t.name for t in self.public_tags)\n\n app_registry.register('tagging', TaggingAppDataContainer)\n\nThis should give you access to `'tagging'` namespace in any defined `AppDataField`::\n\n from blog_app.models import BlogPost\n\n bp = BlogPost()\n assert bp.app_data.tagging.tag_string() == \"\"\n\n\nAdditional Options\n~~~~~~~~~~~~~~~~~~\n\nNote that if you don't need to add custom methods to your container you can\njust use a factory to create the subclass::\n\n app_registry.register('tagging', AppDataContainer.from_form(TaggingAppDataForm))\n\nAdditionaly you can restrict the registration to a given model::\n\n from blog_app.models import BlogPost\n\n app_registry.register('tagging', TaggingAppDataContainer, BlogPost)\n\nExtending Forms\n***************\n\n`django-appdata` supplies a `MultiForm` class - a wrapper around django's `ModelForm`\nwith optional added sub-forms that corresponds to namespaces registered in the\nmodel's `AppDataField`, typically the extendable app would create and use a\n`MultiForm` instead of a regular `ModelForm`::\n\n from app_data.forms import multiform_factory\n from .models import BlogPost\n\n BlogPostMultiForm = multiform_factory(BlogPost)\n\nAnd when using that app any project can add additional sub-forms to that `MultiForm`::\n\n from blog_app.forms import BlogPostMultiForm\n\n BlogPostMultiForm.add_form('tagging', {'fields': ['public_tags']})\n\nThis way when the reusable app's code can remain unchanged and we can inject\nadditional form logic to its processing.\n\nAdditional Options\n~~~~~~~~~~~~~~~~~~\n\nAny arguments and keyword arguments are passed without change to the\n`ModelForm` class the `MultiForm` is wrapping so even if you have custom args\nfor your `ModelForm` everything will still work::\n\n from django.forms.models import BaseModelForm\n\n class ModelFormWithUser(ModelForm):\n def __init__(self, user, *args, **kwargs):\n self.user = user\n super(ModelFormWithUser, self).__init__(*args, **kwargs)\n\n BlogPostMultiForm = multiform_factory(BlogPost, form=ModelFormWithUser)\n\nAnd of course you are not limited to the use of a factory function::\n\n from app_data import MultiForm\n\n class MyMultiForm(MultiForm):\n ModelForm = BlogPostModelForm\n\nMultiForms in Admin\n*******************\n\nIf you wish to add your own code to the admin interface, just use\n`AppDataModelAdmin`::\n\n from django.contrib import admin\n from app_data.admin import AppDataModelAdmin\n from blog_app.models import BlogPost\n\n class BlogPostAdmin(AppDataModelAdmin):\n # due to bug in django's admin validation we need to use\n # declared_fieldsets instead of just fieldsets\n declared_fieldsets = [\n (None, {'fields': ['text', ]}),\n ('Tagging', {'fields': [('tagging.public_tags', 'tagging.admin_tags')]})\n ]\n admin.site.register(BlogPost, BlogPostAdmin)\n\nAdditional Options\n~~~~~~~~~~~~~~~~~~\n\nAs with django's admin and forms you can supply your own `MultiForm` class by\nusing the `multiform` attribute of `AppDataModelAdmin`.\n\nBehind the scenes\n*****************\n\n`django-appdata` uses a `TextField` to store the data on the model using JSON\nand django's forms framework for (de)serialization and validation of the data.\n\nWhen accessing the containers in the field we will try to locate the\nappropriate container in the registry. If none is found, plain data will be\nreturned if present (dict). To assure everything working properly we recommend\nputting some sort of init code in place for your project that will make sure all\nthe registration is done before any actual code is run. We are using a module\ncalled `register` in our apps and then a `piece of code`_ similar to admin's\nautodiscover to iterate through installed apps and load this module.\n\n.. _`piece of code`: https://github.com/ella/ella/blob/master/ella/utils/installedapps.py#L27\n\nBuild status\n************\n\n:Master branch:\n\n .. image:: https://secure.travis-ci.org/MichalMaM/django-appdata.png?branch=master\n :alt: Travis CI - Distributed build platform for the open source community\n :target: http://travis-ci.org/#!/MichalMaM/django-appdata", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/MichalMaM/django-appdata/", "keywords": null, "license": "BSD", "maintainer": null, "maintainer_email": null, "name": "django-appdata-mam", "package_url": "https://pypi.org/project/django-appdata-mam/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-appdata-mam/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/MichalMaM/django-appdata/" }, "release_url": "https://pypi.org/project/django-appdata-mam/0.1.7/", "requires_dist": null, "requires_python": null, "summary": "Extandable field that enables Django apps to store their data on your models.", "version": "0.1.7" }, "last_serial": 2352528, "releases": { "0.1.6": [ { "comment_text": "", "digests": { "md5": "246bc5f1d67677066579fe61f0676d37", "sha256": "81826329809d5005ae6146f131d5fd5416264fd9c054ec273cbdf34e8473e5d9" }, "downloads": -1, "filename": "django_appdata_mam-0.1.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "246bc5f1d67677066579fe61f0676d37", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 15239, "upload_time": "2016-03-07T13:34:00", "url": "https://files.pythonhosted.org/packages/b2/18/6b09c41b07b4ed14753e18fc91a0a2c286f3acb67cfa7d3a6f6036fe32e2/django_appdata_mam-0.1.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cf447ccac66c3ba23766831862ac41ed", "sha256": "e1dc10b7eef16df253b10b68b07392560ae3b52a907fc51110577f806d6eeef4" }, "downloads": -1, "filename": "django-appdata-mam-0.1.6.tar.gz", "has_sig": false, "md5_digest": "cf447ccac66c3ba23766831862ac41ed", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18379, "upload_time": "2016-03-07T13:33:46", "url": "https://files.pythonhosted.org/packages/43/d8/5100069bab0b9bee86363ea18bb0100a18281b3625df08e6b8ada8798d03/django-appdata-mam-0.1.6.tar.gz" } ], "0.1.7": [ { "comment_text": "", "digests": { "md5": "b9e08a9f6adb8a9c5329e9f308386c40", "sha256": "f3d66e8863006ff1db2a4390774aa5049797265d0ceabe6444e860113a7860e8" }, "downloads": -1, "filename": "django_appdata_mam-0.1.7-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b9e08a9f6adb8a9c5329e9f308386c40", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 15245, "upload_time": "2016-08-26T10:44:16", "url": "https://files.pythonhosted.org/packages/3b/45/abdbe20ff0bc1f7de54ddedbf60ee8ef49734aca0c0d4b79b54494cbf6cb/django_appdata_mam-0.1.7-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "667f5263346da54da3927c660369f6c6", "sha256": "f0d83c9a71208b351324e28a520518c9f96810f82d0700c2f3fc559aa0daa109" }, "downloads": -1, "filename": "django-appdata-mam-0.1.7.tar.gz", "has_sig": false, "md5_digest": "667f5263346da54da3927c660369f6c6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18493, "upload_time": "2016-08-26T10:44:13", "url": "https://files.pythonhosted.org/packages/9d/57/e83ecc144691a788b051b6e68fbf6d61775db41a7075b663a4c0853ef45a/django-appdata-mam-0.1.7.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b9e08a9f6adb8a9c5329e9f308386c40", "sha256": "f3d66e8863006ff1db2a4390774aa5049797265d0ceabe6444e860113a7860e8" }, "downloads": -1, "filename": "django_appdata_mam-0.1.7-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "b9e08a9f6adb8a9c5329e9f308386c40", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 15245, "upload_time": "2016-08-26T10:44:16", "url": "https://files.pythonhosted.org/packages/3b/45/abdbe20ff0bc1f7de54ddedbf60ee8ef49734aca0c0d4b79b54494cbf6cb/django_appdata_mam-0.1.7-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "667f5263346da54da3927c660369f6c6", "sha256": "f0d83c9a71208b351324e28a520518c9f96810f82d0700c2f3fc559aa0daa109" }, "downloads": -1, "filename": "django-appdata-mam-0.1.7.tar.gz", "has_sig": false, "md5_digest": "667f5263346da54da3927c660369f6c6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18493, "upload_time": "2016-08-26T10:44:13", "url": "https://files.pythonhosted.org/packages/9d/57/e83ecc144691a788b051b6e68fbf6d61775db41a7075b663a4c0853ef45a/django-appdata-mam-0.1.7.tar.gz" } ] }