Django 1.9 Python3.5
I am using tastypie to consume an external api
I am creating a class to handle the json response from a restful api. I know the data types coming back from the api but do not know how to declare a few of them.
This is how I declare them in Golang
PosterPath string `json:"poster_path"`
Adult bool `json:"adult"`
Overview string `json:"overview"`
ReleaseDate string `json:"release_date"`
GenreIds []int `json:"genre_ids"`
Id int `json:"id"`
OriginalTitle string `json:"original_title"`
OriginalLanguage string `json:"original_language"`
Title string `json:"title"`
BackdropPath string `json:"backdrop_path"`
Popularity float64 `json:"popularity"`
VoteCount int `json:"vote_count"`
Video bool `json:"video"`
VoteAverage float64 `json:"vote_average"`
From my understanding this is how I should declare them with DJjango
class Movies(Resource):
PosterPath = fields.URLField(attribute='poster_path')
Adult = fields.BooleanField(attribute='adult')
Overview = fields.CharField(attribute='overview')
ReleaseDate = fields.CharField(attribute='release_date')
GenreIds = fields.**Array of Ints**(attribute='genre_ids')
Id = fields.IntegerField(attribute='id')
OriginalTitle = fields.CharField(attribute='original_title')
OriginalLanguage = fields.CharField(attribute='original_language')
Title = fields.CharField(attribute='title')
BackdropPath = fields.URLField(attribute='backdrop_path')
Popularity = fields.DecimalField(attribute='popularity')
VoteCount = fields.IntegerField(attribute='vote_count')
Video = fields.BooleanField(attribute='video')
VoteAverage = fields.DecimalField(attribute='vote_average')
This field
GenreIds = fields.**Array of Ints**(attribute='genre_ids')
It is an array of ints. What is the correct way to handle the json of this type? It looks like this,
"genre_ids": [
18,
10402
],