0 Replies Latest reply on Jan 26, 2009 12:16 PM by Huuuze

    How can I use Flex to access foreign-keyed fields in Django?

    Huuuze
      I have the following Django and Flex code:

      ------------------------
      Django
      ------------------------
      class Author(models.Model):
      name = models.CharField(max_length=30)

      class Book(models.Model):
      title = models.CharField(max_length=30)
      author = models.ForeignKeyField(Author)

      ------------------------
      Flex
      ------------------------
      package com.myproject.models.vo
      {
      [Bindable]
      [RemoteClass(alias="myproject.models.Book")]

      public class BookVO
      {
      public var id:int;
      public var title:String;
      public var author: AuthorVO;
      }

      }

      As you can see in this example, Author is a foreign key in my Book model. Now I'd like to acccess the author's name when I call my BookVO in Flex. As such, I'd expect code like the following to work, but "author_name" results in a null:

      ------------------------
      var book = new BookVO();
      var author_name = book.author.name;
      ------------------------

      I realize I could call an AuthorVO directly, but the crux of this question is how can you retrieve foreign-keyed values using Flex when your VOs are bound to a remote object? I'm currently using PyAMF to bridge the gap between Flex and Django, but I'm not sure that's relevant.