简体   繁体   English

没有数据库关系的ForeignKey和ManyToMany

[英]ForeignKey and ManyToMany without db relation

I have a question - is it possible to create a model with some relations, but when syncing database through manage.py syncdb not to create database relations? 我有一个问题-是否可以创建具有某些关系的模型,但是在通过manage.py syncdb同步数据库时不创建数据库关系吗? Just for example to have many-to-many tables and handle it through django ORM but without db foreign keys? 例如,仅具有多对多表并通过django ORM处理它但没有db外键?

Not by default, you could of course implement your own database Field which stores an integer pointing to the specific record. 当然不是默认情况下,您当然可以实现自己的数据库Field ,该Field存储指向特定记录的整数。 This could then used to lookup a model for that type, but you throw away all the checking a database does for you. 然后,这可以用来查找该类型的模型,但是您却放弃了数据库为您所做的所有检查。

Is there any specific reason why you want this? 您是否有任何特定原因想要这样做?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM