3

how do I add arguments to Django signals so that the associated receiver can use those arguments? Reading the docs I've not been able to figure myself. Thanks

Example:

def callback(sender, instance, **kwargs):
    # I want to work with extra here!
    extra = kwargs.get(extra, None)
    if extra:
        # do something with extra
        pass

The receiver is connected to the signal this way:

pre_save.connect(callback)
Paolo
  • 17,649
  • 21
  • 81
  • 115

1 Answers1

4

pre_save is not a signal that you send, but rather Django emits it by default: changing its arguments is probably very complicated and likely to break things.

On signals you define, you can add all the arguments you want; to see how, look at the docs (kindly linked by @Ignacio).

Agos
  • 17,687
  • 10
  • 54
  • 68