Skip to main content

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

  1. Install singleton-admin.

  2. Add “singleton_admin” to your INSTALLED_APPS:

    INSTALLED_APPS = [
        ...
        'singleton_admin',
    ]
  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

singleton-admin-1.0.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distributions

singleton_admin-1.0.0-py2.py3-none-any.whl (4.9 kB view details)

Uploaded Python 2 Python 3

singleton_admin-1.0.0-py2-none-any.whl (4.9 kB view details)

Uploaded Python 2

File details

Details for the file singleton-admin-1.0.0.tar.gz.

File metadata

File hashes

Hashes for singleton-admin-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9e0b588a49509ad0ccdec5457faa7974369ecd6e74291cc6a43d150de6643374
MD5 f69997987661fa7eb0892afd58f69cc2
BLAKE2b-256 14cd77d583f48cd680d74e7bd9885a75f8d3d1d2a34e39bd25da81b96400b51f

See more details on using hashes here.

File details

Details for the file singleton_admin-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for singleton_admin-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8700b0234e266c500b9fad8870177ec748a8f2347c07bca15b35a6caf271672a
MD5 ddff2f8401135ddc393339fbcbb759ae
BLAKE2b-256 767511cb847f14ee37ff96ea468a5856c1878636721944543e686ec2147eb415

See more details on using hashes here.

File details

Details for the file singleton_admin-1.0.0-py2-none-any.whl.

File metadata

File hashes

Hashes for singleton_admin-1.0.0-py2-none-any.whl
Algorithm Hash digest
SHA256 72e97e9bf4927d7fce0bed041cd6b10156cffb62a7d334db34e576ed73cec28e
MD5 e9ce6b545f7299a1331a29fcb68ce93f
BLAKE2b-256 8f9d76d73d36b3dc53342bf8520e62560a139df5ecbb0b7c3667974e25ff0289

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page