singleton-admin
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)
Release files for singleton-admin 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| singleton-admin-1.0.0.tar.gz | 3.7 kB | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| singleton_admin-1.0.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
| singleton_admin-1.0.0-py2-none-any.whl | Python 2 | none | any | Details |
Total release size: 13.5 kB
Release files / singleton-admin-1.0.0.tar.gz
| Download URL | singleton-admin-1.0.0.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9e0b588a49509ad0ccdec5457faa7974369ecd6e74291cc6a43d150de6643374
|
|
BLAKE2b-256 checksum How to use checksums |
14cd77d583f48cd680d74e7bd9885a75f8d3d1d2a34e39bd25da81b96400b51f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / singleton_admin-1.0.0-py2.py3-none-any.whl
| Download URL | singleton_admin-1.0.0-py2.py3-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
8700b0234e266c500b9fad8870177ec748a8f2347c07bca15b35a6caf271672a
|
|
BLAKE2b-256 checksum How to use checksums |
767511cb847f14ee37ff96ea468a5856c1878636721944543e686ec2147eb415
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / singleton_admin-1.0.0-py2-none-any.whl
| Download URL | singleton_admin-1.0.0-py2-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
72e97e9bf4927d7fce0bed041cd6b10156cffb62a7d334db34e576ed73cec28e
|
|
BLAKE2b-256 checksum How to use checksums |
8f9d76d73d36b3dc53342bf8520e62560a139df5ecbb0b7c3667974e25ff0289
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |