Skip to main content

This package provides a way to ensure singleton classes can only have one instance in the Django admin panel. It is taken from Mezzanine by Stephen McDonald.

Project description

=====
django-singleton-admin
=====

This package provides a way to ensure singleton classes can only have one instance in the
Django admin panel. The package contains:

* admin.py, which defines the SingletonAdmin class, preventing adding if an instance already exists.
* templates/admin/singleton_enabled_base.html, which hides the relevant "add" buttons on the admin.

The admin.py file is taken directly from Mezzanine by Stephen McDonald,
https://bitbucket.org/stephenmcd/mezzanine/src/

The template file is taken from a talk at SyDjango by Stephen McDonald,
http://blog.jupo.org/2012/10/26/sydjango-talk-django-admin-missing-manual/


Requirements
--------------

See Mezzanine for more details.


Quick start
-----------

1. Add the app to your INSTALLED_APPS setting like this::

INSTALLED_APPS = (
...
'django_singleton_admin',
)

2. In your singleton model's admin.py file, register it with the admin using this class, e.g.::

from django_singleton_admin.admin import SingletonAdmin

class GlobalSettingsAdmin(SingletonAdmin):
pass

admin.site.register(BSGlobalSettings, GlobalSettingsAdmin)


3. Extend the admin template "admin/base_site.py" using the provided base instead of
of the usual "admin/base.html", i.e. using:

{% extends "admin/singleton_enabled_base.html" %}

Note that this template uses the "extrastyle" block, so if you also override that, you
will need to copy the contents of the provided template into your code instead.
(In that case you may not need to add the app to your installed apps either.)

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

django-singleton-admin-0.0.4.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django-singleton-admin-0.0.4.tar.gz.

File metadata

File hashes

Hashes for django-singleton-admin-0.0.4.tar.gz
Algorithm Hash digest
SHA256 a49d42c32fea5f196e1bb36cd37f07ba11957d2e01f0385eb3aa205325a80103
MD5 53e7d937f36652ef87f30d5ad5e00b29
BLAKE2b-256 b1cc5d32508804b6074d13056ed18ebcd6cfaa4887e56c4f442285541ee95fbd

See more details on using hashes here.

File details

Details for the file django-singleton-admin-0.0.4.macosx-10.7-intel.exe.

File metadata

File hashes

Hashes for django-singleton-admin-0.0.4.macosx-10.7-intel.exe
Algorithm Hash digest
SHA256 b8ad3fc48333aaf0579335afe15fc6faa3f076f03a1efff642023862777bfed8
MD5 72fce011ecde83d4fed7176db9c6918c
BLAKE2b-256 2957b9034c30f9aea0ddeed7c883daff79aa9797f98a0c30d6e6a6664f608c8d

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