File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change 22Views for the clubs app.
33"""
44
5+ import json
56from rest_framework import status
67from rest_framework .decorators import api_view , permission_classes , throttle_classes
78from rest_framework .permissions import AllowAny
@@ -35,18 +36,24 @@ def get_clubs(request):
3536 )
3637
3738 # Convert to list of dictionaries
38- clubs_data = [
39- {
39+ clubs_data = []
40+ for club in filtered_queryset :
41+ # Handle categories - parse JSON if it's a string, otherwise use as-is
42+ categories = club .categories
43+ if isinstance (categories , str ):
44+ categories = json .loads (categories )
45+ else :
46+ categories = []
47+
48+ clubs_data .append ({
4049 "id" : club .id ,
4150 "club_name" : club .club_name ,
42- "categories" : club . categories ,
51+ "categories" : categories ,
4352 "club_page" : club .club_page ,
4453 "ig" : club .ig ,
4554 "discord" : club .discord ,
4655 "club_type" : club .club_type ,
47- }
48- for club in filtered_queryset
49- ]
56+ })
5057
5158 return Response ({"clubs" : clubs_data })
5259 except Exception as e :
Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ def scrape_all():
133133 res .append (
134134 {
135135 "club_name" : club_info ["club_name" ],
136- "categories" : "; " . join ( club_info ["categories" ]),
136+ "categories" : club_info ["categories" ],
137137 "club_page" : club_info ["club_page" ],
138138 "ig" : club_info ["ig" ],
139139 "discord" : club_info ["discord" ],
You can’t perform that action at this time.
0 commit comments