Skip to content

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

License

Notifications You must be signed in to change notification settings

byteweaver/django-singleactiveobject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#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

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages