在视图中,我正在尝试基于产品序列化器创建基于django oscar产品型号的新产品。我总是会遇到此错误' NoneType'对象没有属性'以下是我的代码
from serializers import CategorySerializer, ProductSerializer, ProductClassSerializer
from oscar.apps.catalogue.models import Product, Category, ProductClass
class ProductViewSet(viewsets.ModelViewSet):
"""
A viewset for viewing and editing product instances.
"""
serializer_class = ProductSerializer
queryset = Product.objects.all()
# create a product
def create(self, request, format=None):
data = json.loads(request.body)
serializer = ProductSerializer(data=data)
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_201_CREATED)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
class ProductSerializer(serializers.ModelSerializer):
class Meta:
model = Product
答案 0 :(得分:1)
您可能在代码中的其他位置尝试访问Select
Key1,
Value1
into #TempTable
FROM OPENXML(@handle, '//ValueSet/Values', 1)
WITH
(
key1 VARCHAR(MAX),
value1 varchar(100)
)
,其中product.attributes
等于product