2👍
✅
It is that you have used many = True
in the view when you pass the data to the serializer, but you are in fact only sending a single message.
def post(self, request, formate = None):
serializer = SignupSerializer(data= signup_filtered_data)
See the actual answer:
Actual answer
1👍
A Much cleaner approach is using filters and serializer with a class-based view
A example of that is using mixins.
Permissions Classes DjangoRest
filters.py
class SignupFilter(django_filters.FilterSet):
class Meta:
model = Signup
fields = [
'user_name',
]
views.py
class YourNameView(mixins.CreateModelMixin,
viewsets.GenericViewSet):
permission_classes = [permissions.IsAuthenticated, ] # Permission Classes
pagination_class = PageNumberPagination # Pagination Classes
serializer_class = SignupSerializer # Your Serializer
filter_backends = [DjangoFilterBackend] #This need to added on settings.py
filter_class = SignupFilter # Your filter Class
queryset = Signup.objects.all()
def post(self, request, *args, **kwargs):
return self.create(request, *args, **kwargs)
- [Django]-AttributeError: 'User' object has no attribute 'check_password' error in Django?
- [Django]-Efficient SELECT with complex WHERE condition – do I need to store a column with the calculated value?
Source:stackexchange.com