开发者

Django: Would object creation involving FK still work when the 2 tables involved are in different databases?

I have a Django model:

class Note(models.Model) : 
    text = models.TextField() 
    owner = models.ForeignKey(User) 

If Note and User are located on different da开发者_C百科tabases, would the following still work?

note = Note(text='hello world', owner=request.user) 

I understand that join will not work across databases, but will creating object instances using FK like above still work?

Thanks.


Django does not support cross-database relations, as stated in their documentation: http://docs.djangoproject.com/en/1.3/topics/db/multi-db/#cross-database-relations

So no, your snippet won't work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜