Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
fix!: router error due to already existed basename
Browse files Browse the repository at this point in the history
Exception in thread django-main-thread:
2024-04-15 14:56:18 Traceback (most recent call last):
2024-04-15 14:56:18   File "/opt/pyenv/versions/3.12.2/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
2024-04-15 14:56:18     self.run()
2024-04-15 14:56:18   File "/opt/pyenv/versions/3.12.2/lib/python3.12/threading.py", line 1010, in run
2024-04-15 14:56:18     self._target(*self._args, **self._kwargs)
2024-04-15 14:56:18   File "/openedx/venv/lib/python3.12/site-packages/django/utils/autoreload.py", line 64, in wrapper
2024-04-15 14:56:18     fn(*args, **kwargs)
2024-04-15 14:56:18   File "/openedx/venv/lib/python3.12/site-packages/django/core/management/commands/runserver.py", line 118, in inner_run
2024-04-15 14:56:18     self.check(display_num_errors=True)
2024-04-15 14:56:18   File "/openedx/venv/lib/python3.12/site-packages/django/core/management/base.py", line 419, in check
2024-04-15 14:56:18     all_issues = checks.run_checks(
2024-04-15 14:56:18                  ^^^^^^^^^^^^^^^^^^
2024-04-15 14:56:18   File "/openedx/venv/lib/python3.12/site-packages/django/core/checks/registry.py", line 76, in run_checks
2024-04-15 14:56:18     new_errors = check(app_configs=app_configs, databases=databases)
2024-04-15 14:56:18                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-15 14:56:18   File "/openedx/venv/lib/python3.12/site-packages/django/core/checks/urls.py", line 13, in check_url_config
2024-04-15 14:56:18     return check_resolver(resolver)
2024-04-15 14:56:18            ^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-15 14:56:18   File "/openedx/venv/lib/python3.12/site-packages/django/core/checks/urls.py", line 23, in check_resolver
2024-04-15 14:56:18     return check_method()
2024-04-15 14:56:18            ^^^^^^^^^^^^^^
2024-04-15 14:56:18   File "/openedx/venv/lib/python3.12/site-packages/django/urls/resolvers.py", line 416, in check
2024-04-15 14:56:18     for pattern in self.url_patterns:
2024-04-15 14:56:18                    ^^^^^^^^^^^^^^^^^
2024-04-15 14:56:18   File "/openedx/venv/lib/python3.12/site-packages/django/utils/functional.py", line 48, in __get__
2024-04-15 14:56:18     res = instance.__dict__[self.name] = self.func(instance)
2024-04-15 14:56:18                                          ^^^^^^^^^^^^^^^^^^^
2024-04-15 14:56:18   File "/openedx/venv/lib/python3.12/site-packages/django/urls/resolvers.py", line 602, in url_patterns
2024-04-15 14:56:18     patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
2024-04-15 14:56:18                        ^^^^^^^^^^^^^^^^^^^
2024-04-15 14:56:18   File "/openedx/venv/lib/python3.12/site-packages/django/utils/functional.py", line 48, in __get__
2024-04-15 14:56:18     res = instance.__dict__[self.name] = self.func(instance)
2024-04-15 14:56:18                                          ^^^^^^^^^^^^^^^^^^^
2024-04-15 14:56:18   File "/openedx/venv/lib/python3.12/site-packages/django/urls/resolvers.py", line 595, in urlconf_module
2024-04-15 14:56:18     return import_module(self.urlconf_name)
2024-04-15 14:56:18            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-15 14:56:18   File "/opt/pyenv/versions/3.12.2/lib/python3.12/importlib/__init__.py", line 90, in import_module
2024-04-15 14:56:18     return _bootstrap._gcd_import(name[level:], package, level)
2024-04-15 14:56:18            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-15 14:56:18   File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
2024-04-15 14:56:18   File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
2024-04-15 14:56:18   File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
2024-04-15 14:56:18   File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
2024-04-15 14:56:18   File "<frozen importlib._bootstrap_external>", line 995, in exec_module
2024-04-15 14:56:18   File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
2024-04-15 14:56:18   File "/openedx/ecommerce/ecommerce/urls.py", line 23, in <module>
2024-04-15 14:56:18     from ecommerce.extensions.urls import urlpatterns as extensions_patterns
2024-04-15 14:56:18   File "/openedx/ecommerce/ecommerce/extensions/urls.py", line 11, in <module>
2024-04-15 14:56:18     url(r'^api/', include(('ecommerce.extensions.api.urls', 'api'))),
2024-04-15 14:56:18                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-15 14:56:18   File "/openedx/venv/lib/python3.12/site-packages/django/urls/conf.py", line 34, in include
2024-04-15 14:56:18     urlconf_module = import_module(urlconf_module)
2024-04-15 14:56:18                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-15 14:56:18   File "/opt/pyenv/versions/3.12.2/lib/python3.12/importlib/__init__.py", line 90, in import_module
2024-04-15 14:56:18     return _bootstrap._gcd_import(name[level:], package, level)
2024-04-15 14:56:18            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-15 14:56:18   File "/openedx/ecommerce/ecommerce/extensions/api/urls.py", line 6, in <module>
2024-04-15 14:56:18     url(r'^v2/', include(('ecommerce.extensions.api.v2.urls', 'v2'))),
2024-04-15 14:56:18                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-15 14:56:18   File "/openedx/venv/lib/python3.12/site-packages/django/urls/conf.py", line 34, in include
2024-04-15 14:56:18     urlconf_module = import_module(urlconf_module)
2024-04-15 14:56:18                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-15 14:56:18   File "/opt/pyenv/versions/3.12.2/lib/python3.12/importlib/__init__.py", line 90, in import_module
2024-04-15 14:56:18     return _bootstrap._gcd_import(name[level:], package, level)
2024-04-15 14:56:18            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-15 14:56:18   File "/openedx/ecommerce/ecommerce/extensions/api/v2/urls.py", line 175, in <module>
2024-04-15 14:56:18     router.register(r'partners', partner_views.PartnerViewSet, basename='partner') \
2024-04-15 14:56:18     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-15 14:56:18   File "/openedx/venv/lib/python3.12/site-packages/rest_framework_extensions/routers.py", line 57, in register
2024-04-15 14:56:18     self._register(*args, **kwargs)
2024-04-15 14:56:18   File "/openedx/venv/lib/python3.12/site-packages/rest_framework_extensions/routers.py", line 54, in _register
2024-04-15 14:56:18     return super().register(*args, **kwargs)
2024-04-15 14:56:18            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-04-15 14:56:18   File "/openedx/venv/lib/python3.12/site-packages/rest_framework/routers.py", line 59, in register
2024-04-15 14:56:18     raise ImproperlyConfigured(msg)
2024-04-15 14:56:18 django.core.exceptions.ImproperlyConfigured: Router with basename "partner" is already registered. Please provide a unique basename for viewset "<class 'ecommerce.extensions.api.v2.views.partners.PartnerViewSet'>"
  • Loading branch information
Muhammad Faraz Maqsood authored and Muhammad Faraz Maqsood committed Apr 19, 2024
1 parent 346d7dc commit d8469d5
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions ecommerce/extensions/api/v2/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,19 @@
order_views.ManualCourseEnrollmentOrderViewSet,
basename='manual-course-enrollment-order'
)
router.register(r'partners', partner_views.PartnerViewSet) \
.register(r'catalogs', catalog_views.CatalogViewSet,
basename='partner-catalogs', parents_query_lookups=['partner_id'])
router.register(r'partners', partner_views.PartnerViewSet) \
.register(r'products', product_views.ProductViewSet,
basename='partner-product', parents_query_lookups=['stockrecords__partner_id'])
partner_router = router.register(r'partners', partner_views.PartnerViewSet, basename='partner')
partner_router.register(
r'catalogs',
catalog_views.CatalogViewSet,
basename='partner-catalogs',
parents_query_lookups=['partner_id'],
)
partner_router.register(
r'products',
product_views.ProductViewSet,
basename='partner-product',
parents_query_lookups=['stockrecords__partner_id'],
)
router.register(r'products', product_views.ProductViewSet, basename='product')
router.register(r'vouchers', voucher_views.VoucherViewSet, basename='vouchers')
router.register(r'stockrecords', stockrecords_views.StockRecordViewSet, basename='stockrecords')
Expand Down

0 comments on commit d8469d5

Please sign in to comment.