def METHOD_NAME(self, attrs):
    """ Update the model with external data (usually passed via API call). """
    # There are possible downstream effects of settings self.verification_deadline to null,
    # so don't assign it a value here unless it is specifically included in attrs.
    if 'verification_deadline' in attrs:
        self.verification_deadline = attrs.get('verification_deadline')
    existing_modes = {mode.mode_slug: mode for mode in self.modes}
    merged_modes = set()
    merged_mode_keys = set()
    for posted_mode in attrs.get('modes', []):
        merged_mode = existing_modes.get(posted_mode.mode_slug, CourseMode())
        merged_mode.course_id = self.id
        merged_mode.mode_slug = posted_mode.mode_slug
        merged_mode.mode_display_name = posted_mode.mode_slug
        merged_mode.min_price = posted_mode.min_price
        merged_mode.currency = posted_mode.currency
        merged_mode.sku = posted_mode.sku
        merged_mode.bulk_sku = posted_mode.bulk_sku
        merged_mode.expiration_datetime = posted_mode.expiration_datetime
        merged_mode.save()
        merged_modes.add(merged_mode)
        merged_mode_keys.add(merged_mode.mode_slug)
    # Masters degrees are not sold through the eCommerce site.
    # So, Masters course modes are not included in PUT calls to this API,
    # and their omission which would normally cause them to be deleted.
    # We don't want that to happen, but for the time being,
    # we cannot include in Masters modes in the PUT calls from eCommerce.
    # So, here's hack to handle Masters course modes, along with any other
    # modes that end up in that boat.
    MODES_TO_NOT_DELETE = {
        CourseMode.MASTERS,
    }
    modes_to_delete = set(existing_modes.keys()) - merged_mode_keys
    modes_to_delete -= MODES_TO_NOT_DELETE
    self._deleted_modes = [existing_modes[mode] for mode in modes_to_delete]
    self.modes = list(merged_modes)