Closed modekano closed 4 years ago
when i used Read & Write Serializers as below: serializers:
class CashOutInReaderSerializer(serializers.ModelSerializer):
class Meta:
model = CashOutIn
fields = ('id', 'amount', 'currency', 'note','customer' ,'created_at', 'is_transfer')
depth=1
class CashOutInWriteSerializer(serializers.ModelSerializer):
class Meta:
model = CashOutIn
fields = ('id', 'amount', 'currency', 'note','customer' ,'created_at', 'is_transfer')``
views:
class CashOutInView(generics.ListCreateAPIView):
queryset = CashOutIn.objects.all()
write_serializer_class = CashOutInWriteSerializer
read_serializer_class = CashOutInReaderSerializer
i get this error:
File "D:\django\mproject\transfer\transfers\urls.py", line 14, in <module>
path('', include(router.urls))
File "C:\Users\FIRSTT~1\Envs\transfer\lib\site-packages\rest_framework\routers.py", line 125, in urls
self._urls = self.get_urls()
File "C:\Users\FIRSTT~1\Envs\transfer\lib\site-packages\rest_framework\routers.py", line 386, in get_urls
urls = super(DefaultRouter, self).get_urls()
File "C:\Users\FIRSTT~1\Envs\transfer\lib\site-packages\rest_framework\routers.py", line 284, in get_urls
routes = self.get_routes(viewset)
File "C:\Users\FIRSTT~1\Envs\transfer\lib\site-packages\rest_framework\routers.py", line 200, in get_routes
extra_actions = viewset.get_extra_actions()
AttributeError: type object 'CashOutInView' has no attribute 'get_extra_actions'
Please paste your urls.py code. I think you used router for ListCreateAPIView, router is only used for viewset inherited classes.
Find the examples and explanations here
Description
Describe what you were trying to get done. Tell us what happened, what went wrong, and what you expected to happen.
What I Did