vendredi 26 août 2016

Use CharField as a string

I want to create a model where I just put in two fields and the rest is generated with API requests, the generation I've got but I can't get the CharField in a usable string format. So on field is:
name = models.CharField(max_length=250, default='default')

And I want to run it through:
name = self.name.replace(' ', '+') movieData = (json.loads(str(urllib2.urlopen('http://ift.tt/19GbbGf' + name + '&y=&plot=short&r=json').read(),'utf-8'))) movieYear = movieData.get('Year')
Saving movieYear as a field. Thanks in advanced.




Aucun commentaire:

Enregistrer un commentaire