@receiver(post_save, sender=Review)
def rating_update(sender, instance, *args, **kwargs):
all_ads = Advert.objects.filter(profile_id=instance.ad.profile.id)
rev_stars = 3
rev_count = 1
for rev in Review.objects.filter(status='active'):
if rev.ad in all_ads:
rev_count += 1
rev_stars += rev.stars
instance.ad.profile.rating = round(rev_stars//rev_count)
instance.ad.profile.save()
document.location.href = document.location.href.replace('#open_login', '');
document.location.href = document.location.href