python - How to get data from youtube api automaticly when you add item on django -


i have model class in django such as

class youtubevideo(models.model):     title = models.charfield(max_length=200,blank=true,null=true)     video_id = models.charfield(max_length=2000, unique=true)     duration = models.charfield(blank=true,null=true,max_length=200)      def __unicode__(self):         return self.title 

i want duration (and other data) when add video_id on admin interface. how can trigger crawler after adding item.

extend save method of model:

def save(self, **kwargs):     if self.video_id not none , self.duration none:         self.duration = call_youtube_to_get_duration()     return super(youtubevideo, self).save(**kwargs) 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -