From 8ffa2d9c3c597fc7da02e13d3bc05c456bfd4066 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 21 May 2025 11:27:22 +0530 Subject: [PATCH] Replace more f-strings --- hosting/models.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hosting/models.py b/hosting/models.py index f9bdc751..4c039fef 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -774,8 +774,10 @@ class UserCardDetail(AssignPermissionsMixin, models.Model): if user_card_details.count() > 1: # Log a warning about the duplicate entries logger.warning( - f"Multiple UserCardDetail objects found for stripe_customer_id={stripe_cust.id} and card_id={card_id}. " - f"Found {user_card_details.count()} objects. Using the first one." + "Multiple UserCardDetail objects found for stripe_customer_id={} and card_id={}. " + "Found {} objects. Using the first one.".format( + stripe_cust.id, card_id, user_card_details.count() + ) ) # Use the first object found user_card_detail = user_card_details.first() @@ -787,13 +789,19 @@ class UserCardDetail(AssignPermissionsMixin, models.Model): # Depending on expected behavior, you might want to raise an error or handle this case. # If the original get() call happened here, it would raise DoesNotExist. logger.error( - f"No UserCardDetail found for stripe_customer_id={stripe_cust.id} and card_id={card_id}." + "No UserCardDetail found for stripe_customer_id={} and card_id={}.".format( + stripe_cust.id, card_id + ) + ) + raise UserCardDetail.DoesNotExist( + "No UserCardDetail found for customer {}, card {}".format( + stripe_cust.id, card_id + ) ) - raise UserCardDetail.DoesNotExist(f"No UserCardDetail found for customer {stripe_cust.id}, card {card_id}") except Exception as e: # Catch other potential exceptions during the filter/get process if necessary - logger.error(f"An unexpected error occurred while fetching UserCardDetail: {e}") + logger.error("An unexpected error occurred while fetching UserCardDetail: {}".format(e)) raise return user_card_detail