You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for this great library, I really love this. I have come across an issue however, when I wanted to use rest_flex_fields.filter_backends.FlexFieldsFilterBackend. When I added it to the configuration of DRF, the following import error occured:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "d:\workspace\my_project\api\.env\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "d:\workspace\my_project\api\.env\lib\site-packages\django\core\management\__init__.py", line 377, in execute
django.setup()
File "d:\workspace\my_project\api\.env\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "d:\workspace\my_project\api\.env\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "d:\workspace\my_project\api\.env\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "d:\workspace\my_project\api\.env\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "d:\workspace\my_project\api\my_app\models.py", line 9, in <module>
from utils.mixins import ResultsModelMixin, TrackFieldChangesMixin
File "d:\workspace\my_project\api\utils\mixins\__init__.py", line 4, in <module>
from .results import ResultsModelMixin, ResultsListViewMixin
File "d:\workspace\my_project\api\utils\mixins\results\__init__.py", line 2, in <module>
from .views import ResultsListViewMixin
File "d:\workspace\my_project\api\utils\mixins\results\views.py", line 5, in <module>
from rest_framework.generics import get_object_or_404
File "d:\workspace\my_project\api\.env\lib\site-packages\rest_framework\generics.py", line 24, in <module>
class GenericAPIView(views.APIView):
File "d:\workspace\my_project\api\.env\lib\site-packages\rest_framework\generics.py", line 43, in GenericAPIView
filter_backends = api_settings.DEFAULT_FILTER_BACKENDS
File "d:\workspace\my_project\api\.env\lib\site-packages\rest_framework\settings.py", line 220, in __getattr__
val = perform_import(val, attr)
File "d:\workspace\my_project\api\.env\lib\site-packages\rest_framework\settings.py", line 168, in perform_import
return [import_from_string(item, setting_name) for item in val]
File "d:\workspace\my_project\api\.env\lib\site-packages\rest_framework\settings.py", line 168, in <listcomp>
return [import_from_string(item, setting_name) for item in val]
File "d:\workspace\my_project\api\.env\lib\site-packages\rest_framework\settings.py", line 177, in import_from_string
return import_string(val)
File "d:\workspace\my_project\api\.env\lib\site-packages\django\utils\module_loading.py", line 17, in import_string
module = import_module(module_path)
File "d:\workspace\my_project\api\.env\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "d:\workspace\my_project\api\.env\lib\site-packages\rest_flex_fields\__init__.py", line 3, in <module>
from .views import FlexFieldsModelViewSet
File "d:\workspace\my_project\api\.env\lib\site-packages\rest_flex_fields\views.py", line 6, in <module>
from rest_framework import viewsets
File "d:\workspace\my_project\api\.env\lib\site-packages\rest_framework\viewsets.py", line 199, in <module>
class GenericViewSet(ViewSetMixin, generics.GenericAPIView):
AttributeError: module 'rest_framework.generics' has no attribute 'GenericAPIView'
Removing the imports from .views import FlexFieldsModelViewSet from __init__.py and from rest_framework.viewsets import GenericViewSet from filter_backends.py solved the issue for me. Probably the later could be placed behind the TYPE_CHECKING flag from typing, but I have no idea about the first one.
I solved the problem by importing FlexFieldsFilterBackend directly from the settings.py module and inserting it into the backend settings.
However, I decided not to use that library due to the Schema format incompatible with drf_spectacular.
Thanks for this great library, I really love this. I have come across an issue however, when I wanted to use
rest_flex_fields.filter_backends.FlexFieldsFilterBackend
. When I added it to the configuration of DRF, the following import error occured:Removing the imports
from .views import FlexFieldsModelViewSet
from__init__.py
andfrom rest_framework.viewsets import GenericViewSet
fromfilter_backends.py
solved the issue for me. Probably the later could be placed behind theTYPE_CHECKING
flag fromtyping
, but I have no idea about the first one.Env:
The text was updated successfully, but these errors were encountered: