diff --git a/backend/server/worldtravel/serializers.py b/backend/server/worldtravel/serializers.py index e3f70109..386f673a 100644 --- a/backend/server/worldtravel/serializers.py +++ b/backend/server/worldtravel/serializers.py @@ -19,7 +19,10 @@ def get_num_regions(self, obj): return Region.objects.filter(country=obj).count() def get_num_visits(self, obj): - return VisitedRegion.objects.filter(region__country=obj).count() + request = self.context.get('request') + if request and hasattr(request, 'user'): + return VisitedRegion.objects.filter(region__country=obj, user_id=request.user).count() + return 0 class Meta: model = Country