我在python django应用程序中使用sqlite3数据库:我正在定义与实际表模式类似的表结构。
table1 having three column:
1. id | primary key | int
2. name | text
3. address | text
table2 having four column:
1. id | primary key | int
2. name_id | foreign key | int
3. name_info | text
4. address_info | text
table3 having four column:
1. id | primary key | int
2. name_id | foreign key | int
3. edu_info | text
4. busin_info | text
table4 having four column:
1. id | primary key | int
2. name_id | foreign key | int
3. progress_info | text
4. inventory_info | text
等等。。
我想在django中基于forgin key使用in-single查询访问所有表数据。并非所有表都有相同的记录号。
我已经在所有型号中设置了外键。比如:
class table(models.Model):
name = models.ForeignKey(modelname)
使用select_related()
与select_相关的转换为内部连接查询并立即加载所有数据。
相关问题 更多 >
编程相关推荐