Question

I have delusions that I've seen it in some piece of code and it's some variable's state. Example usage would be in signal handlers.

Was it helpful?

Solution

I haven't checked it out yet, but from this discussion, http://code.djangoproject.com/ticket/8399 it seems that loaddata sends out post_save signals.

OTHER TIPS

(8 years later) stumbled upon own question, and the example would be (tested in >=1.11):

from django.db.models.signals import pre_save
from django.dispatch import receiver

@receiver(pre_save) # `post_save` also works
def callback_on_loaddata(sender, **kwargs):
    # 'raw' indicates that loaddata cmd was issued
    if kwargs.get('created', True) and kwargs.get('raw', False):
        # mark on-going loaddata, call kwargs.get('instance').clean() etc.
        ...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top