A Django app that will only allow one instance of a model to be created via the admin site.
Project description
Using singleton-admin will allow users to only add one instance of a model via the django admin site. Once created, the instance can be updated and deleted, but additional instances cannot be created.
This is useful if you’d like to store a page content in the database for example.
I found myself using this package (https://github.com/tttallis/django-singletons) a lot, but some of the code has now been depreciated through newer releases of Django.
I originally had the intention of forking the package and making the fixes, but in the end I ended up re-writing from scratch. The end goal is the same, but with a different approach.
I appreciate that there are probably plenty of packages out there that offer similar functionality, but as I’ve put this together and have used in my own projects, I thought I’d get it out there.
Quick start
Install singleton-admin.
Add “singleton_admin” to your INSTALLED_APPS:
INSTALLED_APPS = [ ... 'singleton_admin', ]
In your apps admin.py file to make your model a singleton-admin you can either do:
from singleton_admin.admin import SingletonAdmin admin.site.register(your_model, SingletonAdmin)
Or if you’d like to add your own admin class:
from singleton_admin.admin import SingletonAdmin class your_model_admin(SingletonAdmin): ... admin.site.register(your_model, your_model_admin)
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
Built Distributions
Hashes for singleton_admin-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8700b0234e266c500b9fad8870177ec748a8f2347c07bca15b35a6caf271672a |
|
MD5 | ddff2f8401135ddc393339fbcbb759ae |
|
BLAKE2b-256 | 767511cb847f14ee37ff96ea468a5856c1878636721944543e686ec2147eb415 |
Hashes for singleton_admin-1.0.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72e97e9bf4927d7fce0bed041cd6b10156cffb62a7d334db34e576ed73cec28e |
|
MD5 | e9ce6b545f7299a1331a29fcb68ce93f |
|
BLAKE2b-256 | 8f9d76d73d36b3dc53342bf8520e62560a139df5ecbb0b7c3667974e25ff0289 |