Skip to content

Commit 2def73d

Browse files
committed
profile handles errors with watchlist
1 parent 16523c2 commit 2def73d

File tree

5 files changed

+526
-641
lines changed

5 files changed

+526
-641
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Flicks
22

3-
A movie reflection and review app where users can explore a daily film pick and share their thoughts. Watch more. Share your take.
3+
A movie reflection and review app where users can explore a daily film pick and share their thoughts.
44

55
**Live Demo**: [https://reviews-app123.vercel.app/register](https://reviews-app123.vercel.app/register)
66

@@ -16,3 +16,4 @@ A movie reflection and review app where users can explore a daily film pick and
1616
- **Django** + **Django REST Framework**
1717
- **PostgreSQL**
1818

19+
Note: The backend is hosted on Render’s free tier, which may result in a short delay (a few seconds) when registering a new user due to cold starts after periods of inactivity. I've included a demo video in case the website encounters issues handling requests.

backend/api/serializers.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,10 @@ class WatchlistItemSerializer(serializers.ModelSerializer):
7272
class Meta:
7373
model = WatchlistItem
7474
fields = ['id', 'imdb_id', 'title', 'year', 'poster', 'added_at', 'watched', 'rating', 'notes', 'imdb_rating']
75-
read_only_fields = ['added_at']
75+
read_only_fields = ['id', 'added_at']
76+
extra_kwargs = {
77+
'imdb_rating': {'required': False},
78+
'notes': {'required': False},
79+
'rating': {'required': False},
80+
'watched': {'required': False}
81+
}

backend/api/views.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,11 @@ def get(self, request):
9898
status=status.HTTP_200_OK
9999
)
100100

101-
# Get detailed info for each movie including rating
101+
# Get detailed info for first 10 movies
102+
detailed_results = []
102103
if 'Search' in search_data:
103-
detailed_results = []
104104
for movie in search_data['Search'][:10]: # Limit to first 10 results
105+
# Get additional movie details including rating
105106
detail_response = requests.get(
106107
'http://www.omdbapi.com/',
107108
params={
@@ -112,12 +113,21 @@ def get(self, request):
112113
)
113114
if detail_response.status_code == 200:
114115
detail_data = detail_response.json()
115-
movie['imdbRating'] = detail_data.get('imdbRating', 'N/A')
116-
detailed_results.append(movie)
116+
# Only include movies with posters and required fields
117+
if (detail_data.get('Poster', 'N/A') != 'N/A' and
118+
detail_data.get('Title') and
119+
detail_data.get('Year')):
120+
detailed_results.append({
121+
'imdbID': detail_data['imdbID'],
122+
'Title': detail_data['Title'],
123+
'Year': detail_data['Year'],
124+
'Poster': detail_data['Poster'],
125+
'imdbRating': detail_data.get('imdbRating', 'N/A')
126+
})
127+
if len(detailed_results) >= 10: # Ensure we never exceed 10 results
128+
break
117129

118-
search_data['Search'] = detailed_results
119-
120-
return Response(search_data)
130+
return Response({'Search': detailed_results})
121131

122132
except requests.Timeout:
123133
return Response(

backend/mydatabase

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)