There is an error "getattr(): attribute name must be string", I don't know how to solve this,
views.py:
class VideoViewset(ResponseViewMixin, mixins.ListModelMixin, mixins.RetrieveModelMixin, viewsets.GenericViewSet):
def post(self, request, *args, **kwargs):
try:
serializer = VideoSerializers(data=request.data)
if not serializer.is_valid():
return self.jp_error_response('HTTP_400_BAD_REQUEST', self.error_msg_list(serializer.errors))
serializer.save()
return self.jp_response(s_code='HTTP_201_CREATED', data={'video': serializer.data})
except Exception as e:
print(e)
return self.jp_error_response('HTTP_500_INTERNAL_SERVER_ERROR', 'EXCEPTION', [str(e), ])
serializers.py:
class VideoSerializers(serializers.ModelSerializer):
class Meta:
model = Video
fields = ('video_type', 'relevance', 'difficulty', 'category', 'sub_category')
models.py:
class Video(BaseModel, Timestamps, SoftDelete):
relevance_difficulty_choices = (
('low', 'Low'),
('medium', 'Medium'),
('high', 'High')
)
video_type_choices = (
('micro', 'Micro'),
('mini', 'Mini'),
('grand', 'Grand')
)
create_date = models.DateTimeField(auto_now_add=True, null=True)
video_type = models.CharField(max_length=50, choices=video_type_choices, null=False)
relevance = models.CharField(max_length=50, choices=relevance_difficulty_choices, null=False)
difficulty = models.CharField(max_length=50, choices=relevance_difficulty_choices, null=False)
category = models.CharField(max_length=254, null=False, blank=False)
sub_category = models.CharField(max_length=254, null=False, blank=False)
created_by = models.ForeignKey(Employee, null=True, on_delete=models.CASCADE)
contributer = models.CharField(max_length=254, null=False)
file_url = models.CharField(max_length=254, null=True, blank=False)
urls.py:
router = routers.SimpleRouter(trailing_slash=False)
router.register(r'categories', VideoCategoryViewSet, 'all-video-categories')
router.register(r'search', VideoListViewset, 'search')
router.register(r'video-add', VideoViewset, 'video-add')
This is my traceback:
System check identified no issues (0 silenced).
April 01, 2021 - 12:06:22
Django version 3.1.3, using settings 'main.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
getattr(): attribute name must be string
Internal Server Error: /api/e/video/video-add
"POST /api/e/video/video-add HTTP/1.1" 500 115
getattr(): attribute name must be string
Internal Server Error: /api/e/video/video-add
"POST /api/e/video/video-add HTTP/1.1" 500 115
getattr(): attribute name must be string
Internal Server Error: /api/e/video/video-add
i am beginer in django,What's I am doing wrong? here using postman to check,which showing the above error.