I\'m wiring up a custom post_save signal and noticed that I can\'t seem to find an easy way to pass a set of kwargs.
During the save itself (inside a custom form)
We can pass additional arguments as below:
def save(self, commit=True):
user = super(CustomFormThing, self).save(commit=False)
#set some other attrs on user here ...
if commit:
user.save(signal_kwargs={'_some': 'some', '_other': 'other'})
return user
And you can get it from the post save method like:
@receiver(post_save, sender=User)
def create_profile(sender, instance, created, **kwargs):
some_id = kwargs.get('some', None)
other_id = kwargs.get('other', None)
if created:
#do something with the kwargs above...