[Fixed]-How to get data from youtube api automaticly when you add item on django

1👍

Extend the save method of your model:

def save(self, **kwargs):
    if self.video_id is not None and self.duration is None:
        self.duration = call_youtube_to_get_duration()
    return super(YoutubeVideo, self).save(**kwargs)

Leave a comment