Issue
I would appreciate some help. Does anyone know why this signal is only being triggered only when the "xp value" is different from the one that already exist ? so eg. if a UserLeaderboardTracking objects already exist for that user with the value 10 the it won't create it otherwise it will .
def create_user_leaderboard_tracking(sender, instance, *args, **kwargs):
if instance.xp_collected == 0:
pass
else:
UserLeaderboardTracking.objects.get_or_create(user=instance.user,
xp_value=instance.xp_collected)
Solution
I was using <get_or_create> and instead I should have use
def create_user_leaderboard_tracking(sender, instance, *args, **kwargs):
if instance.xp_collected == 0:
pass
else:
UserLeaderboardTracking.objects.create(user=instance.user,
xp_value=instance.xp_collected) ```
Answered By - Riccardo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.