PyAMF and django ForeignKey

6905 단어 django

 
In order to support this, PyAMF needs to provide a synonym mapping between fields. Until then, you could use  IExternalizable  (although clumsily):
classUserProfile(model.Model): user = models.ForeignKey(User, unique=True) blurb = models.CharField( max_length=200,null=True, blank=True)public= models.BooleanField(default=True)class __amf__: external =Truedef __writeamf__(self, output): output.writeObject(self.id) output.writeObject(self.blurb) output.writeObject(self.public)def __readamf__(self, input):self.id = input.readObject()self.blurb = input.readObject()self.public= input.readObject()

With the corresponding Flex code:
[RemoteClass(alias="...")][Bindable]publicclassUserProfileimplementsIExternalizable{publicfunctionUserProfile(){}publicvar id:int;publicvar blurb:String;publicvar _public:Boolean;publicfunction writeExternal(output:IDataOutput){ output.writeObject(id); output.writeObject(blurb); output.writeObject(_public);}publicfunction readExternal(input:IDataInput){ id = input.readObject(); blurb = input.readObject(); _public = input.readObject();}}

Note I haven't tested the above code, but should work in principle.
Btw, can you go into greater detail about what was confusing about the  documentation ? I would love to make that as clear possible for new users.

좋은 웹페이지 즐겨찾기