3👍
You’re using the wrong parameter. sender
is the class to which the signal is connected. You need to also accept the instance parameter .
@receiver(post_save, sender=es_event)
def set_csv_path(sender, instance, **kwargs):
rel_path = "reg_csv/Registered_{}.csv".format(instance.id)
path = os.path.join(settings.MEDIA_ROOT,rel_path)
instance.reg_applicants = path
instance.save()
0👍
I also had the similar problem, turns out that the arguments of the receiver method cannot be renamed, you have to keep the original name as it is.
in my case my receiver was something like this,
def my_receiver(sender, my_instance, created, **kwargs)
.
I had to change to (sender, instance, created, **kwargs)
- [Django]-Django instance.id=None when uploading image
- [Django]-Django – SMTPAuthenticationError
- [Django]-Get current user in Django admin
- [Django]-InlineModelAdmin not showing up on admin page
Source:stackexchange.com