# Buildsheet autogenerated by ravenadm tool -- Do not edit. NAMEBASE= python-django-solo VERSION= 2.2.0 KEYWORDS= python VARIANTS= v11 v12 SDESC[v11]= Djanjo manipulator of database singletons (3.11) SDESC[v12]= Djanjo manipulator of database singletons (3.12) HOMEPAGE= https://github.com/lazybird/django-solo/ CONTACT= Python_Automaton[python@ironwolf.systems] DOWNLOAD_GROUPS= main SITES[main]= PYPIWHL/1a/ae/dcfce0d26386c96d8a789fd0a154433ea316cac4e9498bd3fe1695b7a96c DISTFILE[1]= django_solo-2.2.0-py3-none-any.whl:main DF_INDEX= 1 SPKGS[v11]= single SPKGS[v12]= single OPTIONS_AVAILABLE= PY311 PY312 OPTIONS_STANDARD= none VOPTS[v11]= PY311=ON PY312=OFF VOPTS[v12]= PY311=OFF PY312=ON DISTNAME= django_solo-2.2.0.dist-info GENERATED= yes [PY311].RUN_DEPENDS_ON= python-Django:single:v11 [PY311].USES_ON= python:v11,wheel [PY312].RUN_DEPENDS_ON= python-Django:single:v12 [PY312].USES_ON= python:v12,wheel [FILE:2873:descriptions/desc.single] Django Solo =========== [image] +---------------------------+ | | | | | \ | Django Solo helps working with singletons: | /\ | database tables that only have one row. | >=)'> | Singletons are useful for things like global | \/ | settings that you want to edit from the admin | / | instead of having them in Django settings.py. | | | | +---------------------------+ Features -------- Solo helps you enforce instantiating only one instance of a model in django. * You define the model that will hold your singleton object. * django-solo gives helper parent class for your model and the admin classes. * You get an admin interface that's aware you only have one object. * You can retrieve the object from templates. * By enabling caching, the database is not queried intensively. Use Cases -------- Django 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". * Global or default settings * An image slider that has many slides * A page section that has sub-sections * A team bio with many team members There are many cases where it makes sense for the parent in a one to many relationship to be limited to a single instance. Usage Example ```python # models.py from django.db import models from solo.models import SingletonModel class SiteConfiguration(SingletonModel): site_name = models.CharField(max_length=255, default='Site Name') maintenance_mode = models.BooleanField(default=False) def __str__(self): return "Site Configuration" class Meta: verbose_name = "Site Configuration" ` `python # admin.py from django.contrib import admin from solo.admin import SingletonModelAdmin from config.models import SiteConfiguration admin.site.register(SiteConfiguration, SingletonModelAdmin) ` `python # There is only one item in the table, you can get it this way: from .models import SiteConfiguration config = SiteConfiguration.objects.get() # get_solo will create the item if it does not already exist config = SiteConfiguration.get_solo() ``` In your model, note how you did not have to provide a `verbose_name_plural` field - That's because Django Solo uses the `verbose_name` instead. If 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: ```python class SiteConfiguration(SingletonModel): singleton_instance_id = 24 [FILE:113:distinfo] 81ad30a412d36f8bdbe5622df06d6051e4264344222858c919e990d339e677e8 15630 django_solo-2.2.0-py3-none-any.whl