{ "info": { "author": "Grigoriy Bezyuk", "author_email": "me@gbezyuk.ru", "bugtrack_url": null, "classifiers": [], "description": "This fork contains compatibility updates required to play nice with django-grappelli.\nOriginal lazybird's Django-Solo README is left unchanged bellow.\n\nDjango Solo\n===========\n\n\n +---------------------------+\n | |\n | |\n | \\ | Django Solo helps working with singletons:\n | /\\ | database tables that only have one row.\n | >=)'> | Singletons are useful for things like global\n | \\/ | settings that you want to edit from the admin\n | / | instead of having them in Django settings.py.\n | |\n | |\n +---------------------------+\n\n\nFeatures\n--------\n\nSolo helps you enforce instantiating only one instance of a model in django.\n\n* You define the model that will hold your singleton object.\n* django-solo gives helper parent class for your model and the admin classes.\n* You get an admin interface that's aware you only have one object.\n* You can retrieve the object from templates.\n* By enabling caching, the database is not queried intensively.\n\nUse Cases\n--------\n\nDjango Solo is also great for use with singleton objects that have a one to many relationship. Like the use case below where you have a 'Home Slider\" that has many \"Slides\".\n\n* Global or default settings\n* An image slider that has many slides\n* A page section that has sub-sections\n* A team bio with many team members\n\nThere are many cases where it makes sense for the parent in a one to many relationship to be limited to a single instance.\n\nUsage Example\n\n```python\n# models.py\n\nfrom django.db import models\nfrom solo.models import SingletonModel\n\nclass SiteConfiguration(SingletonModel):\n site_name = models.CharField(max_length=255, default='Site Name')\n maintenance_mode = models.BooleanField(default=False)\n\n def __unicode__(self):\n return u\"Site Configuration\"\n\n class Meta:\n verbose_name = \"Site Configuration\"\n```\n\n```python\n# admin.py\n\nfrom django.contrib import admin\nfrom solo.admin import SingletonModelAdmin\nfrom config.models import SiteConfiguration\n\nadmin.site.register(SiteConfiguration, SingletonModelAdmin)\n\n# There is only one item in the table, you can get it this way:\nfrom .models import SiteConfiguration\nconfig = SiteConfiguration.objects.get()\n\n# get_solo will create the item if it does not already exist\nconfig = SiteConfiguration.get_solo()\n```\n\n\nIn your model, note how you did not have to provide a `verbose_name_plural` field -\nThat's because Django Solo uses the `verbose_name` instead.\n\nIf you're changing an existing model (which already has some objects stored in the database) to a singleton model, you can explicitly provide the id of the row in the database for django-solo to use. This can be done by setting `singleton_instance_id` property on the model:\n\n```python\nclass SiteConfiguration(SingletonModel):\n singleton_instance_id = 24\n # (...)\n```\n\nInstallation\n------------\n\nThis application requires Django >= 1.6.\n\n* Install the package using `pip install django-solo`\n* Add ``solo`` or ``solo.apps.SoloAppConfig`` to your ``INSTALLED_APPS`` setting.\n\nThis is how you run tests:\n\n ./manage.py test solo --settings=solo.tests.settings\n\n\nAdmin\n-----\n\nThe standard Django admin does not fit well when working with singleton,\nfor instance, if you need some global site settings to be edited in the admin.\nDjango Solo provides a modified admin for that.\n\n\n![django-solo admin](https://raw.github.com/lazybird/django-solo/master/docs/images/django-solo-admin.jpg \"django-solo admin\")\n\n\n* In the admin home page where all applications are listed, we have a `config`\n application that holds a singleton model for site configuration.\n* The configuration object can only be changed, there's no link for \"add\" (1).\n* The link to the configuration page (2) directly goes to the form page - no\n need for an intermediary object list page, since there's only one object.\n* The edit page has a modified breadcrumb (3) to avoid linking to the\n intermediary object list page.\n* From the edit page, we cannot delete the object (4) nor can we add a new one (5).\n\n\nAvailability from templates\n---------------------------\n\nThe singleton object can be retrieved from template by giving the Django model\ndotted path:\n\n```django\n{% get_solo 'app_label.ModelName' as my_config %}\n```\n\n\nExample:\n\n```django\n{% load solo_tags %}\n{% get_solo 'config.SiteConfiguration' as site_config %}\n{{ site_config.site_name }}\n{{ site_config.maintenance_mode }}\n```\n\n\nIf you're extending a template, be sure to use the tag in the proper scope.\n\nRight:\n\n```django\n{% extends \"index.html\" %}\n{% load solo_tags %}\n\n{% block content %}\n {% get_solo 'config.SiteConfiguration' as site_config %}\n {{ site_config.site_name }}\n{% endblock content %}\n```\n\nWrong:\n\n```django\n{% extends \"index.html\" %}\n{% load solo_tags %}\n{% get_solo 'config.SiteConfiguration' as site_config %}\n\n{% block content %}\n {{ site_config.site_name }}\n{% endblock content %}\n```\n\n\nCaching\n-------\n\nBy default caching is disabled: every time `get_solo` retrieves the singleton\nobject, there will be a database query.\n\nYou can enable caching to only query the database when initially retrieving the\nobject. The cache will also be updated when updates are made from the admin.\n\nThe cache timeout is controlled via the `SOLO_CACHE_TIMEOUT` settings.\nThe cache backend to be used is controlled via the `SOLO_CACHE` settings.\n\n\nSettings\n--------\n\n### Template Tag Name\n\nYou can retrieve your singleton object in templates using the `get_solo`\ntemplate tag.\n\nYou can change the name `get_solo` using the\n`GET_SOLO_TEMPLATE_TAG_NAME` setting.\n\n```python\nGET_SOLO_TEMPLATE_TAG_NAME = 'get_config'\n```\n\n### Cache backend\n\nDjango provides a way to define multiple cache backends with the `CACHES`\nsettings. If you want the singleton object to be cached separately, you\ncould define the `CACHES` and the `SOLO_CACHE` settings like this:\n\n```python\nCACHES = {\n 'default': {\n 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',\n 'LOCATION': '127.0.0.1:11211',\n },\n 'local': {\n 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',\n },\n}\n\nSOLO_CACHE = 'local'\n```\n\n\nCaching will be disabled if set to `None`.\n\n\n### Cache timeout\n\nThe cache timeout in seconds.\n\n```python\nSOLO_CACHE_TIMEOUT = 60*5 # 5 mins\n```\n\n### Cache prefix\n\nThe prefix to use for the cache key.\n\n```python\nSOLO_CACHE_PREFIX = 'solo'\n```\n\n================\nGetting the code\n================\n\nThe code is hosted at https://github.com/lazybird/django-solo/\n\nCheck out the latest development version anonymously with::\n\n $ git clone git://github.com/lazybird/django-solo.git", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/gbezyuk/django-solo-grappelli/tarball/1.1.2", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/gbezyuk/django-solo-grappelli", "keywords": "django,solo,singleton,grappelli", "license": "Creative Commons Attribution 3.0 Unported", "maintainer": null, "maintainer_email": null, "name": "django-solo-grappelli", "package_url": "https://pypi.org/project/django-solo-grappelli/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-solo-grappelli/", "project_urls": { "Download": "https://github.com/gbezyuk/django-solo-grappelli/tarball/1.1.2", "Homepage": "http://github.com/gbezyuk/django-solo-grappelli" }, "release_url": "https://pypi.org/project/django-solo-grappelli/1.1.2/", "requires_dist": null, "requires_python": null, "summary": "django-solo helps working with singletons: things like global settings that you want to edit from the admin site.", "version": "1.1.2" }, "last_serial": 2447706, "releases": { "1.1.1": [ { "comment_text": "", "digests": { "md5": "324bebdbd737d2fe34e536a6d9af4642", "sha256": "1049fd8f5810b104f9c3640a81e45773a47fe2df1d80a3cfed5dc3d608dee169" }, "downloads": -1, "filename": "django-solo-grappelli-1.1.1.tar.gz", "has_sig": false, "md5_digest": "324bebdbd737d2fe34e536a6d9af4642", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7477, "upload_time": "2015-09-19T09:31:10", "url": "https://files.pythonhosted.org/packages/c2/73/e85498c830413041d75209ae90a66f27f086d1d7d88dbf1691d0e0f43a58/django-solo-grappelli-1.1.1.tar.gz" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "271eed8a90fe1c6714370c2938c94473", "sha256": "2f13ce26d6dfb66603d6aa82c0c314e9fb079a3e71a0ddf65605b7785307d3c0" }, "downloads": -1, "filename": "django-solo-grappelli-1.1.2.tar.gz", "has_sig": false, "md5_digest": "271eed8a90fe1c6714370c2938c94473", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8501, "upload_time": "2016-11-07T19:52:19", "url": "https://files.pythonhosted.org/packages/1b/98/4927a6d972caf36e80310f64b100675009ba4bcf8ba719cea275ed4fa521/django-solo-grappelli-1.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "271eed8a90fe1c6714370c2938c94473", "sha256": "2f13ce26d6dfb66603d6aa82c0c314e9fb079a3e71a0ddf65605b7785307d3c0" }, "downloads": -1, "filename": "django-solo-grappelli-1.1.2.tar.gz", "has_sig": false, "md5_digest": "271eed8a90fe1c6714370c2938c94473", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8501, "upload_time": "2016-11-07T19:52:19", "url": "https://files.pythonhosted.org/packages/1b/98/4927a6d972caf36e80310f64b100675009ba4bcf8ba719cea275ed4fa521/django-solo-grappelli-1.1.2.tar.gz" } ] }