I'm using django_registration_redux package to handle registering new users. Then I have a set of categories, which I want each new user to follow them by default. So I have to run following code immediately after a user object created:
for category in categories:
f = Follow(user=user.username, category=category)
f.save()
After reading django Docs, I guessed that adding following method to the UserProfile
model would work:
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.connect(follow_def_cat, sender=User)
But it seems I couldn't connect saving user signal to the function.