From d2238c2cb2f632165e6631b9f0af0767b472ea06 Mon Sep 17 00:00:00 2001 From: tianyi Date: Thu, 9 May 2024 06:10:39 +0000 Subject: [PATCH] bug fix: return the same pic's info --- backend/randpic/random_picture.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/backend/randpic/random_picture.py b/backend/randpic/random_picture.py index 9d4d7ed..7397156 100644 --- a/backend/randpic/random_picture.py +++ b/backend/randpic/random_picture.py @@ -5,13 +5,15 @@ from .models import Picture pics=Picture.objects.order_by("?") def get_random_picture_url(): - return "https://cdn.clf3.org/tianyi-random/"+pics[0].name+".webp" + selected_pic=pics[0] + return "https://cdn.clf3.org/tianyi-random/"+selected_pic.name+".webp" def get_random_picture_meta(): + selected_pic=pics[0] return { - "name":pics[0].name, - "url":"https://cdn.clf3.org/tianyi-random/"+pics[0].name+".webp", - "description":pics[0].description, - "author":pics[0].author, - "author_url":pics[0].author_url, - "original_url":pics[0].original_url + "name":selected_pic.name, + "url":"https://cdn.clf3.org/tianyi-random/"+selected_pic.name+".webp", + "description":selected_pic.description, + "author":selected_pic.author, + "author_url":selected_pic.author_url, + "original_url":selected_pic.original_url } \ No newline at end of file