dimanche 31 juillet 2016

How to obtain an Django Foreign Key object in ember.js?

I have a model called "Summary" and a foreign key object called "TrainStatistics"

class Summary(models.Model):
    train_statistics = models.ForeignKey(
    'TrainStatistics',
    on_delete=models.CASCADE,
    blank=True,
    null=True,
)

Whenever I try to access it as follows in the ember.js code, I notice that the console.log only gets the id (primary key) of TrainStatistics, rather than the whole object.

statistic_trainStatisticsArray.forEach(function(train_statistic) {
    var trainStatistic_typeStatisticsArray = [];
    trainStatistic_typeStatisticsArray.push(train_statistic.type_statistics)

    var keys = Object.keys(train_statistic);
    console.log("keys for train_statistic: " + keys);

Could someone lead me towards the right direction for this problem?




Aucun commentaire:

Enregistrer un commentaire