我为我的Django应用程序创建了YAML灯具,用于开发和测试目的。但是,在创建许多灯具时,文件中会有很多行重复:
- model: my_app.model
pk: 1
fields:
name: name1
creation_date: 2018-01-01 00:00:00 +00
modification_date: 2018-01-01 00:00:00 +00
- model: my_app.model
pk: 2
fields:
name: name2
creation_date: 2018-01-01 00:00:00 +00
modification_date: 2018-01-01 00:00:00 +00
- model: my_app.model
pk: 3
fields:
name: name3
creation_date: 2018-01-01 00:00:00 +00
modification_date: 2018-01-01 00:00:00 +00
我想要做的是为灯具设置某种模板以消除重复。与此相符:
template: &TEMPLATE
model: my_app.model
fields:
creation_date: 2018-01-01 00:00:00 +00
modification_date: 2018-01-01 00:00:00 +00
- << *TEMPLATE
pk: 1
fields:
name: name1
- << *TEMPLATE
pk: 2
fields:
name: name2
- << *TEMPLATE
pk: 3
fields:
name: name3
有没有办法用Django YAML灯具来实现这个目标?