Is it possible to access the attributes of a model that is related to a foreign key class in javascript if the objects is already serialized?
class One(models.Model):
attr = models.CharField()
accessMe = models.CharField()
class Two(models.Mode):
attr = models.ForeinKey(One)
* Function to serialized
def something(request):
return JsonResponse({'model': model_to_dict(Two.objects.all())})
* How to access in Javascript - JQuery
$.ajax({
complete: function(response){
var howTo = response.model.attr.accessMe;
}
});
On the Jquery Section the variable howTo will have a value of undefined.