@receiver(pre_save, sender=UserProfile)
def user_profile_pre_save_callback(sender, **kwargs):
 user_profile = kwargs['instance']
 if (user_profile.requires_parental_consent() and user_profile.has_profile_image):
  user_profile.profile_image_uploaded_at = None
 user_profile._changed_fields = get_changed_fields_dict(user_profile, sender)

@ receiver ( pre_save , sender = UserProfile ) def user_profile_pre_save_callback ( sender , ** kwargs ) : user_profile = kwargs [ 'instance' ] if ( user_profile . requires_parental_consent ( ) and user_profile . has_profile_image ) : user_profile . profile_image_uploaded_at = None user_profile . _changed_fields = get_changed_fields_dict ( user_profile , sender )
ensure consistency of a user profile before saving it .