我有一个dynamodb表,其中"feed_guid"作为全局二级索引.我想查询该表中的一组feed_guid.由于"feed_guid"不是我的主键,所以我不能使用getBatchItem.当我尝试以下方法时,我收到此错误"KeyConditionExpression中使用的无效运算符:OR".
$options = array(
'TableName' => 'feed',
'IndexName' => 'GuidIndex',
'KeyConditionExpression' => 'feed_guid = :v_guid1 or feed_guid = :v_guid2',
'ExpressionAttributeValues' => array (
':v_guid1' => array('S' => '8a8106e48bdbe81bf88d611f4b2104b5'),
':v_guid2' => array('S' => '19cab76242a6d85717de64fe4f8acbd4')
),
'Select' => 'ALL_ATTRIBUTES',
);
$response = $dynamodbClient->query($options);
Run Code Online (Sandbox Code Playgroud) 我必须将product_id
(这是一个字符串)传递到视图中。在那里我必须根据产品 ID 进行一些数据库操作。如何在该视图中获取该产品 ID?实际上类ProductDetailConfiguration
视图中的参数应该是什么?现在我路过viewsets.ModelViewSet
。实际上,这个 API 调用并不与任何模型完全相关。
# urls.py
url(r'^product-configuration/(?P<product_id>[\w-]+)/$', views.ProductDetailConfiguration, name='product-configuration'),
Run Code Online (Sandbox Code Playgroud)
# 视图.py
class ProductDetailConfiguration(viewsets.ModelViewSet):
queryset = Product.objects.all()
def get_queryset(self, **kwargs):
queryset = Product.objects.all()
product_id = self.request.get('product_id', None)
#filter query set based on the product_id
return queryset
serializer_class = ProductConfigurationSerializer
Run Code Online (Sandbox Code Playgroud) python django django-models django-views django-rest-framework
我试图查询我的dynamodb表以获取feed_guid和status_id = 1.但它返回查询键条件不支持错误.请找到我的表架构和查询.
$result =$dynamodbClient->createTable(array(
'TableName' => 'feed',
'AttributeDefinitions' => array(
array('AttributeName' => 'user_id', 'AttributeType' => 'S'),
array('AttributeName' => 'feed_guid', 'AttributeType' => 'S'),
array('AttributeName' => 'status_id', 'AttributeType' => 'N'),
),
'KeySchema' => array(
array('AttributeName' => 'feed_guid', 'KeyType' => 'HASH'),
),
'GlobalSecondaryIndexes' => array(
array(
'IndexName' => 'StatusIndex',
'ProvisionedThroughput' => array (
'ReadCapacityUnits' => 5,
'WriteCapacityUnits' => 5
),
'KeySchema' => array(
array(
'AttributeName' => 'status_id',
'KeyType' => 'HASH'
),
),
'Projection' => array(
'ProjectionType' => 'ALL'
)
),
array(
'IndexName' …
Run Code Online (Sandbox Code Playgroud) 我的产品模型有一个名为"product_id"的额外字段,它是一个uuid字符串.现在我可以根据主键ID获取产品详细信息.我想更改此信息以使用"product_id"字段获取产品详细信息.
我目前的urls.py
url(r'^products/(?P<pk>[0-9]+)/$', views.ProductDetailCustom.as_view(), name='product-detail'),
Run Code Online (Sandbox Code Playgroud)
现在我这样打电话.
http://127.0.0.1:8000/api/v1/products/1460
Run Code Online (Sandbox Code Playgroud)
我希望这应该是这样的.
http://127.0.0.1:8000/api/v1/products/04396134-3c90-ea7b-24ba-1fb0db11dbe5
Run Code Online (Sandbox Code Playgroud)
views.py
class ProductDetailCustom(generics.RetrieveAPIView):
queryset = Product.objects.all()
serializer_class = ProductCustomSerializer
Run Code Online (Sandbox Code Playgroud)
serializer.py
class ProductCustomSerializer(serializers.ModelSerializer):
class Meta:
model = Product
fields = ('url', 'id','product_id', 'title', 'description','structure','date_created',)
Run Code Online (Sandbox Code Playgroud)
我想我必须包括一个外观领域来实现这个目标.
python django django-models django-views django-rest-framework
我想发送一些关于从codeigniter库发送的电子邮件的额外信息.有没有办法配置或添加这个?
我想对来自我网站的所有外发邮件进行分类.我需要包含sendgrid类别标题以进行跟踪.
我有两个产品的自定义选项.颜色和大小都是下拉列表.在产品详细信息页面中,我必须显示该产品的所有可用颜色.
我尝试了以下代码,它的工作原理.但它返回颜色和大小的所有值.但我只需要颜色值.那就是我想按颜色选择自定义选项.
$_product = $block->getProduct();
foreach($_product->getOptions() as $o){
foreach($o->getValues() as $value){
print_r($value->getData());
}
}
Run Code Online (Sandbox Code Playgroud) 我们可以仅使用全局二级索引来更新dynamodb项目吗?
$response = $dynamodbClient->updateItem(array(
'TableName' => 'feed',
'Key' => array(
'feed_guid' => array('S' => 'ac1e9683832ad2923f0bd84b91f34381'),
'created_date' => array('N' => '1439295833'),
),
"ExpressionAttributeValues" => array (
":val1" => array('N' => '1')
) ,
"UpdateExpression" => $updateExpression,
'ReturnValues' => 'ALL_NEW'
));
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,我想替换关键部分并使用全局二级索引(即user_id)更新项目。
我已经从magento 2 admin(系统>自定义变量)创建了一个自定义变量.我的自定义变量代码是"test_var".
如何在phtml文件中获取该值?
从 django 默认验证器返回的所有错误消息均以点 (.) 结尾。无论如何,是否可以从全局所有消息中删除最后一个点。
或者,如果有人帮助我找到一种方法来捕获这些错误返回函数,我可以修剪最后一个点(如果存在于该部分)。
错误消息示例。
{
"email": [
"This field may not be blank."
]
}
{
"email": [
"Enter a valid email address."
]
}
Run Code Online (Sandbox Code Playgroud) django django-models django-forms django-validation django-rest-framework
在rest api中,我使用“/rest/V1/guest-carts/e3e1fd447e0e315dd761942cf949ce5d/items”方法来获取magento购物车项目。它运作良好,结果是
[
{
"item_id": 100,
"sku": "abc-1",
"qty": 1,
"name": "Product one",
"price": 19,
"product_type": "simple",
"quote_id": "e3e1fd447e0e315dd761942cf949ce5d"
},
{
"item_id": 101,
"sku": "abc-2",
"qty": 1,
"name": "Product two",
"price": 54,
"product_type": "simple",
"quote_id": "e3e1fd447e0e315dd761942cf949ce5d"
}
]
Run Code Online (Sandbox Code Playgroud)
现在我想获取列表中每个产品的图像(可能是缩略图)。有什么办法可以达到这个结果吗?
django ×3
magento ×3
magento2 ×3
bigdata ×2
django-views ×2
magento-2.0 ×2
python ×2
codeigniter ×1
django-forms ×1
email ×1
html-email ×1
magento2.0.2 ×1
nosql ×1
php ×1
r ×1