I can serialize all objects using the following. In views: class ProductDetail(generics.ListAPIView): serializer_class = ProductSerializer def get_queryset(self): return Product.objects.all()
In serializers: class ProductSerializer(serializers.ModelSerializer): class Meta: model = Product fields = ('code', 'name', 'description') When I try to restrict this to one record, I get an error: class ProductDetail(generics.RetrieveAPIView): serializer_class = ProductSerializer def get_queryset(self): pid = int(self.kwargs['pid']) return Product.objects.get(id=pid) Exception Type: AttributeError Exception Value:'Product' object has no attribute 'model' I am guessing that get_queryset is not the right thing to use in this situation. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1a4a658e-4728-4577-a0f6-9fdd5e110f09%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.