'NoneType' object has no attribute 'attributes' while creating a new catalogue product in django oscar -
in views trying create new product based on product serializer based on django oscar product model.i error 'nonetype' object has no attribute 'attributes'.following below code
views.py
serializers import categoryserializer, productserializer, productclassserializer oscar.apps.catalogue.models import product, category, productclass class productviewset(viewsets.modelviewset): """ viewset viewing , editing product instances. """ serializer_class = productserializer queryset = product.objects.all() # create 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)
serializers.py
class productserializer(serializers.modelserializer): class meta: model = product
you probably, somewhere else in code, trying access product.attributes
, product
equals none
Comments
Post a Comment