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
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
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
File details
Details for the file django-singleactiveobject-0.9.1.tar.gz
.
File metadata
- Download URL: django-singleactiveobject-0.9.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 037236b59a4e2e9b39807da539e90229e294b6ca72671b8581af334d82ec83cd |
|
MD5 | 01db39fecd9e4f333a9c9639c4b7fd8c |
|
BLAKE2b-256 | f1689232c448374d04fb67a4afe39d5feb7d32c463149b4ead7b64da1c8a5f6b |