Fix timezone handling for RSVP deadline validation
Updated the RSVP deadline validation to automatically assign UTC as the timezone if none is provided, ensuring consistency. This prevents errors and enforces proper timezone-aware datetime usage.
This commit is contained in:
@@ -51,7 +51,7 @@ class EventBase(BaseModel):
|
||||
def validate_rsvp_deadline(cls, v, values):
|
||||
if v:
|
||||
if not v.tzinfo:
|
||||
raise ValueError("RSVP deadline must be timezone-aware")
|
||||
v = v.replace(tzinfo=timezone.utc)
|
||||
if 'event_date' in values.data:
|
||||
if v > values.data['event_date']:
|
||||
raise ValueError("RSVP deadline must be before event date")
|
||||
|
||||
Reference in New Issue
Block a user