我使用Vue.js 2.5.13并拥有这种结构:
component-one.vue:
<template>
<div>
<input type="text" v-model="input_one">
<component-two></component-two>
</div>
</template>
<script>
import ComponentTwo from 'component-two.vue'
export default {
name: "component-one",
components: {
ComponentTwo
},
data() {
return {
input_one: 'Hello from ComponentOne',
input_two: ... // <-- I want to get value from ComponentTwo input_two (v-model) here
}
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
component-two.vue:
<template>
<div>
<input type="text" v-model="input_two">
</div>
</template>
<script>
export default {
name: "component-two",
data() {
return {
input_one: 'Hello from ComponentTwo'
}
}
} …Run Code Online (Sandbox Code Playgroud) Django 2.0.3,Python 3.6.1
我有标准的 Django 管理面板。对于我的模型之一,我创建list_editable了一些字段(provider和provider_price屏幕截图)。问题是:如何list_editable在某个日期后禁用这些字段进行编辑?
例如,如果现在是March 11, 2018和更旧,字段provider和provider_price被禁用并且不会在列表视图中编辑(仅在单个记录更改视图中)。
我的env是Django 2.0.3,DRF 3.8.2和Python 3.6.4.
我有一个模型serializers.py:
class TransferCostSerializer(serializers.ModelSerializer):
def to_representation(self, instance):
field_view = super().to_representation(instance)
if field_view['is_active']:
return field_view
return None
class Meta:
model = TransferCost
fields = ('id', 'destination', 'total_cost', 'is_active',)
Run Code Online (Sandbox Code Playgroud)
where destinationfield是3个元素的选择字段:
DESTINATION = (
('none', _('I will drive by myself')),
('transfer_airport', _('Only from airport')),
('transfer_round_trip', _('Round trip')),
)
Run Code Online (Sandbox Code Playgroud)
这是我的models.py:
class TransferCost(models.Model):
destination = models.CharField(
_('Transfer Destination'), choices=DESTINATION, max_length=55
)
total_cost = models.PositiveIntegerField(
_('Total cost'), default=0
)
is_active = models.BooleanField(_('Transfer active?'), default=True)
class Meta:
verbose_name …Run Code Online (Sandbox Code Playgroud) 我正在使用 Django 1.11.9 和django-pytest库来测试我的应用程序。另外,我使用 Redis 作为缓存存储。我的问题是 \xe2\x80\x94 如何制作测试缓存存储并在运行测试之前使用测试数据设置它?与 Django 数据库的方式类似。
我想添加一些key: value数据来测试缓存存储(在 Redis 中),运行测试,然后删除所有这些测试数据(清除测试缓存)。