Skip to main content

Model mixin that ensures there is only one active model instance in your database.

Project description

#django-singleactiveobject

Model mixin that ensures there is only one active model instance in your database.

## What is this app good for?
This might come in handy if you store some sort of configuration in your database
but want to be sure there is only one active entry at a time.

## How it works

Upon save() this will check if the current object is active=True and will set
any other active object to active=False ensuring there is only one active.

## Download/Install

### using pip

pip install django-singleactiveobject

### github

git clone https://github.com/byteweaver/django-singleactiveobject

## Usage

```python
from singleactiveobject.models import SingleActiveObjectMixin

class YourModel(SingleActiveObjectMixin):
...your stuff
```

## Testing

Just run the makefile to set up a virtual environment for testing

make

Start the test runner

make test

Project details


Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
django-singleactiveobject-0.9.1.tar.gz (3.8 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page