def get_city_image(self, instance):
try:
city_image = City.objects.get(id=instance.city_id).image.url
except City.DoesNotExist:
#捕获City不存在的异常, 抛出异常或是自己处理
city_image = None
return city_image
filter.first
django filter&&get
最新推荐文章于 2024-07-26 11:48:55 发布