How do I load sub-models with a foriegn key relationship in Backbone.js?
===

Sorry if this is a bit convoluted... I am still learning Backbone.js...

What is the proper way to load & save Backbone models that have sub-models within themselves?  (And should I even be having sub-models?)

For example, (pardon the coffeescript), if I have something like:

    class Address extends Backbone.Model
      urlRoot: '/api/v1/address/'
      url: -> return @urlRoot+@id+'/?format=json'
      defaults: {'city': '', 'state': ''}
    
    class Person extends Backbone.Model
      urlRoot: '/api/v1/person/'
      url: -> return @urlRoot+@id+'/?format=json'
      defaults: { name: 'Anon', address: new Address }

    ... and then I do this ...

    dude = new Person
    dude.set('id',101)
    dude.fetch()
    // Response returns {name: 'The Dude', address: '/api/v1/address/1998/'}
    // And now, dude.get('address') is '/api/v1/address/1998' and no Address object
 
    where = new Address
    where.set('id',1998)
    where.fetch()
    // Response returns {city: 'Venice', state; 'CA'}

**What I want** is to say dude.fetch() and for it to get both the dude and his address, and when I call Backbone.sync('update',dude), I want to save both the dude and his address.  How?

On the backend, I am using tastypie to construct my api for some SQLAlchemy tables (not Django's ORM), and so I have a resource for my Person table and Address table:

    class AddressResource(SQLAlchemyResource):
        class Meta:
            resource_name = 'address'
            object_class = AddressSQLAlchemyORMClass
    
    class PersonResource(SQLAlchemyResource):
        address = ForeignKey(AddressResource, 'address')
        class Meta:
            resource_name = 'person'
            object_class = PersonSQLAlchemyORMClass

Tastypie's [ForeignKey][1] function creates a mapping that returns **the URL** to the address in question.

I tried overloading the Dude.parse() function to call fetch for the Address(), but it wasn't working and it felt wrong, and it raised all sorts of questions:

 1. Should I be modifying my tastypie response to include the Address as a nested object?
 2. If I change to a nested object, should I be use [backbone-relational][2], as in the question http://stackoverflow.com/questions/11316782/backbone-relational-related-models-not-being-created, or is that overkill?
 3. Should I be [overloading the parse()][3] or fetch() function or creating my own backbone.Sync() to get the response and then do this manually?
 4. Since it is one-to-one, should I instead just have one model, instead of a sub-model, and send the information back forth together in one request?

Is there a standard way of doing this?

  [1]: http://django-tastypie.readthedocs.org/en/latest/interacting.html
  [2]: https://github.com/PaulUithol/Backbone-relational/
  [3]: http://paltman.com/2012/04/30/integration-backbonejs-tastypie/