django-commons / drf-excel

An XLSX spreadsheet renderer for Django REST Framework.
BSD 3-Clause "New" or "Revised" License
217 stars 40 forks source link

TypeError: 'module' object is not callable #77

Closed devanghingu closed 1 year ago

devanghingu commented 1 year ago

I tried to use this package for my drf application this is my ViewSet which i defined in my view.py

class HolidayExportViewSet(XLSXFileMixin, ReadOnlyModelViewSet):
    queryset = Data.objects.all()
    serializer_class = data_serializer
    renderer_classes = (XLSXRenderer,)
    filename = 'my_export.xlsx'

but unfortunately i got following error

[13/Sep/2023 15:36:19] "GET /user/data-export/ HTTP/1.1" 500 121066
Internal Server Error: /user/data-export/
Traceback (most recent call last):
  File "/home/dev/projects/lab/test_project/.venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/dev/projects/lab/test_project/.venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/dev/projects/lab/test_project/.venv/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/dev/projects/lab/test_project/.venv/lib/python3.8/site-packages/rest_framework/viewsets.py", line 125, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/dev/projects/lab/test_project/.venv/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/home/dev/projects/lab/test_project/.venv/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/home/dev/projects/lab/test_project/.venv/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/home/dev/projects/lab/test_project/.venv/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/home/dev/projects/lab/test_project/src/hr_management/views/data_export_view.py", line 16, in list
    return super(DataExportViewSet, self).list(request, *args, **kwargs)
  File "/home/dev/projects/lab/test_project/.venv/lib/python3.8/site-packages/rest_framework/mixins.py", line 45, in list
    serializer = self.get_serializer(queryset, many=True)
  File "/home/dev/projects/lab/test_project/.venv/lib/python3.8/site-packages/rest_framework/generics.py", line 110, in get_serializer
    return serializer_class(*args, **kwargs)
TypeError: 'module' object is not callable
[13/Sep/2023 15:36:22] "GET /user/data-export/ HTTP/1.1" 500 121066
devanghingu commented 1 year ago

Closing this issue due to calling my module instead of my actual serializer :sweat_smile: