from schedule.models import EmailTemplate import json html_content = """

Appointment Confirmed

Hello {{CUSTOMER_NAME}},

Your appointment has been confirmed. We look forward to seeing you!

Service: {{SERVICE_NAME}}
Date & Time: {{EVENT_START_DATETIME}}
Duration: {{SERVICE_DURATION}} minutes
With: {{STAFF_NAME}}
View My Appointment

If you need to reschedule or cancel, please contact us at least 24 hours in advance.

{{BUSINESS_NAME}}
{{BUSINESS_EMAIL}} | {{BUSINESS_PHONE}}

""" text_content = """ Hello {{CUSTOMER_NAME}}, Your appointment has been confirmed. We look forward to seeing you! --- Appointment Details: Service: {{SERVICE_NAME}} Date & Time: {{EVENT_START_DATETIME}} Duration: {{SERVICE_DURATION}} minutes With: {{STAFF_NAME}} --- If you need to reschedule or cancel, please contact us at least 24 hours in advance. View your appointment: {{VIEW_APPOINTMENT_LINK}} --- {{BUSINESS_NAME}} {{BUSINESS_EMAIL}} | {{BUSINESS_PHONE}} """ template_name = "Appointment Confirmed" # Assuming this is the name of the template to update try: template = EmailTemplate.objects.get(name=template_name) template.html_content = html_content template.text_content = text_content template.save() print(f"Successfully updated template '{template_name}'.") except EmailTemplate.DoesNotExist: print(f"Error: Template '{template_name}' not found.") except Exception as e: print(f"An error occurred: {e}")