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

c# - Class in a list -

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

Jdbc Odbc Driver error -