Easily edit singleton models in the Django admin site
Project description
Django Singleton Admin
In dynamic applications, it can be somewhat of a pain to have static settings that have to be set in settings.py
. Django Singleton Admin adds an easy way to edit singleton models (e.g a SiteSetting model) to allow administrators to change configuration on the fly.
This is great for things like OAuth settings for third parties, or dynamic settings that you need to pull for your site.
Installation
- Install with Pip
pip install django-singleton-admin-2
- Add
django_singleton_admin
toINSTALLED_APPS
Influenced By
Example
# models.py
from django.db import models
class SiteSettings(models.Model):
site_title = models.CharField(max_length=32)
site_domain = models.CharField(max_length=32)
site_description = models.CharField(max_length=32)
@staticmethod
def get_instance():
return SiteSettings.objects.get_or_create(pk=0)
def __str__(self):
return "Site settings"
# admin.py
from django.contrib import admin
from .models import SiteSettings
from django_singleton_admin.admin import DjangoSingletonModelAdmin
admin.site.register(SiteSettings, DjangoSingletonModelAdmin)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-singleton-admin-2-1.1.0.tar.gz
.
File metadata
- Download URL: django-singleton-admin-2-1.1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 366753fe5660a4adbd142658bc62eeabfd3e6886d3322e94e8e067a1b3b0a814 |
|
MD5 | 5286dbdba0416e162e8ff0b0dfbcf752 |
|
BLAKE2b-256 | bd092418b8c496140231ec75efa3746f57ac246f0646ee8fd5e86ca5bc6c27f5 |