1👍
✅
Put your connect instruction out of the signal method.
def follow_def_cat(sender, instance, created, **kwargs):
if created:
for category in categories:
f = Follow(user=instance.username, category=category)
f.save()
post_save.connetc(follow_def_cat, sender=User)
And remember that follow_def_cat
is not a model method, you should create it at the same level that the model class:
class UserProfile(models.Model):
...
def follow_def_cat(sender, ...):
...
post_save.connect(follow_def_cat, sender=User)
Source:stackexchange.com