Skip to main content

models.UpdateCampaignModel

The payload used to update an existing campaign.

Usage

Source

models.UpdateCampaignModel()

Shares all fields with CreateCampaignModel. As a safeguard, a send_at value that is already in the past is dropped (set to None) before sending, so that updating a campaign does not fail on a stale scheduled time.

Examples

>>> import datetime
>>> from listmonk.models import UpdateCampaignModel
>>> stale = datetime.datetime(2020, 1, 1, tzinfo=datetime.timezone.utc)
>>> UpdateCampaignModel(template_id=1, send_at=stale).send_at is None
True

Methods

Name Description
validate_send_at() Drop a send_at value that is already in the past.

validate_send_at()

Drop a send_at value that is already in the past.

Usage

Source

validate_send_at(fld)

Listmonk rejects updates whose scheduled send time has passed, so a past send_at is replaced with None (unscheduling the campaign).

Parameters
fld: datetime.datetime
The incoming send_at value.
Returns
Optional[datetime.datetime]
The original datetime, or None if it is in the past.