1👍
✅
This issue is caused because the signal sender is the User
model itself. So saving the user instance of one of the profiles will call both the professeur_profil
and etudiant_profil
receivers. One approach to fix this is to change the senders of the receivers to the profile model instead:
@receiver(post_save, sender=Professeur)
def professeur_profil(sender, instance, created, **kwargs):
if created:
group = Group.objects.get(name='prof')
instance.user.groups.add(group)
@receiver(post_save, sender=Etudiant)
def etudiant_profil(sender, instance, created, **kwargs):
if created:
group = Group.objects.get(name='etudiant')
instance.user.groups.add(group)
- [Answered ]-How to remove tags from RichTextField and calculate words saved in RichTextField Django?
Source:stackexchange.com