Welcome to django-observer documentation!¶
Contents:
observer package¶
Subpackages¶
observer.tests package¶
Subpackages¶
Submodules¶
observer.tests.compat module¶
observer.tests.factories module¶
observer.tests.models module¶
observer.tests.test_investigator module¶
Module contents¶
observer.utils package¶
Submodules¶
observer.utils.models module¶
observer.utils.signals module¶
-
observer.utils.signals.
register_reciever
(model, signal, receiver, sender=None, **kwargs)[source]¶ Connect signal and receiver of the model without duplication
Parameters: - model (class) – A target class
- signal (signal) – A django signal
- receiver (reciever) – A django signal receiver
- sender (model) – A model class
- **kwargs – Options passed to the signal.connect method
Returns: True for new registration, False for already registered.
Return type: bool
-
observer.utils.signals.
unregister_reciever
(model, signal, receiver)[source]¶ Disconnect signal and receiver of the model without exception
Parameters: - model (class) – A target class
- signal (signal) – A django signal
- receiver (reciever) – A django signal receiver
Returns: True for success, False for already disconnected.
Return type: bool
Module contents¶
Submodules¶
observer.conf module¶
observer.decorators module¶
observer.investigator module¶
-
class
observer.investigator.
Investigator
(model, include=None, exclude=None)[source]¶ Bases:
object
A model modification investigator
Create an instance of investigator with a model class and call ‘prepare’ method just before save the model. After the model is saved, call ‘investigate’ method and the method will yields the field names modified.
-
get_cached
(pk, ignore_exception=True)[source]¶ Get cached object
Parameters: - pk (any) – A primary key of the object
- ignore_exception (bool) – Return None if the object is not found, if this is False, ObjectDoesNotExist raised
Raises: ObjectDoesNotExist
– When a specified object does not exists in the cache and ignore_exception is False.Returns: object or None
-
get_object
(pk, ignore_exception=True)[source]¶ Get latest object
It try to get the latest (unsaved) object from the database. If ignore_exception is True, return None, otherwise it raise ObjectDoesNotExist exception when no object is found.
Parameters: - pk (any) – A primary key of the object
- ignore_exception (bool) – Return None if the object is not found. if this is False, ObjectDoesNotExist raised.
Raises: ObjectDoesNotExist
– When a specified object does not exists ignore_exception is False.Returns: object or None
-