diff --git a/backend/server/adventures/views.py b/backend/server/adventures/views.py index d0a1b0cb..5ad66971 100644 --- a/backend/server/adventures/views.py +++ b/backend/server/adventures/views.py @@ -143,6 +143,8 @@ def all(self, request): @action(detail=False, methods=['get']) def search(self, request): query = self.request.query_params.get('query', '') + if len(query) < 2: + return Response({"error": "Query must be at least 2 characters long"}, status=400) queryset = Adventure.objects.filter( (Q(name__icontains=query) | Q(description__icontains=query) | Q(location__icontains=query) | Q(activity_types__icontains=query)) & (Q(user_id=request.user.id) | Q(is_public=True)) diff --git a/frontend/src/lib/components/AdventureCard.svelte b/frontend/src/lib/components/AdventureCard.svelte index 8535a0c6..48242085 100644 --- a/frontend/src/lib/components/AdventureCard.svelte +++ b/frontend/src/lib/components/AdventureCard.svelte @@ -161,49 +161,53 @@ {/if}
- There are no adventures to display. Add some using the plus button at the bottom right or try - changing filters! -
+ {#if !error} ++ There are no adventures to display. Add some using the plus button at the bottom right or + try changing filters! +
+ {:else} +{error}
+ {/if}