惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

有赞技术团队
有赞技术团队
G
Google Developers Blog
T
Tailwind CSS Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理
J
Java Code Geeks
P
Proofpoint News Feed
V
Visual Studio Blog
爱范儿
爱范儿
The Cloudflare Blog
博客园 - 叶小钗
V
V2EX
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
M
MIT News - Artificial intelligence
Microsoft Security Blog
Microsoft Security Blog
博客园 - 聂微东
H
Help Net Security
B
Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 【当耐特】
量子位
宝玉的分享
宝玉的分享
WordPress大学
WordPress大学
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

博客园 - BoyeeStudio

FLEX自定义事件 Flex Array 与 ArrayCollection.转自网络 Django Push HTTP Response to users How to sync your github repository after fork from others'. N年没写博客了,手生锈了,准备再来磨磨! CAsyncSocket,CSocket内幕及其用法 Socket中如何设置连接超时(转载 可能用的到) 最近在我的python博客上花时间! P2P相关软件源代码下载 写个perl程序自动下载《南方周末》(2005年12月最后一期,38版,值得一看) wxWidgets开发工具及Makefile的书写!(待续。。。) 用wxWindows编程 -----第一步!(翻译)(系列1) 编VC网络程序遇到一个问题,原来是少了一个LIB。 如何优化C语言代码(程序员必读) 重温经典排序思想--C语言常用排序全解(转载--值得一看) 常用windows API WAP开发FAQ c++资源之不完全导引(全文) (转载) GNU编码标准
PyAMF and django ForeignKey
BoyeeStudio · 2013-07-02 · via 博客园 - BoyeeStudio

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.