0

I'm writing a JavaScript function that makes use of Django objects. I have an object, which I'll call item, which has a field user. So item.user should give me an instance of a Django User object.

Now a User object has a number of subfields, including profile. In Django, I can access this field with {{ user.profile }}. In JavaScript, however, item.user.profile is "undefined". Is there a different syntax, or is some other method of getting the data necessary?

Micah Walter
  • 908
  • 9
  • 19
  • How are you telling Javascript about your Django object? – Daniel Roseman Jun 26 '14 at 14:11
  • 1
    You probably have not serialized the foreign key objects. See this post for example: http://stackoverflow.com/questions/10507011/django-serialize-foreign-key-objects – karthikr Jun 26 '14 at 14:15
  • I'm getting `item` with `$.each(json, function(i,item)`. Is this not already serialized? Can I serialize from within JavaScript? – Micah Walter Jun 26 '14 at 18:11

0 Answers0