Open jayvdb opened 4 years ago
Note that just setting EXPORTER_ROUTER_PATH = ROOT_URLCONF
didnt do the trick. Note I use the DJango layout where there is a project subdirectory with settings.py/urls.py/wsgi.py/etc.
ROOT_URLCONF = '<project_name>.urls'
EXPORTER_ROUTER_PATH = ROOT_URLCONF
File "/usr/lib/python3.8/site-packages/export_app/base.py", line 22, in __init__
self.router = import_string(settings.ROUTER_PATH)
File "/usr/lib/python3.8/site-packages/django/utils/module_loading.py", line 22, in import_string
raise ImportError('Module "%s" does not define a "%s" attribute/class' % (
ImportError: Module "<project_name>" does not define a "urls" attribute/class
Running into the same issues over here as well! Love the concept and all the progress made so far!
it is neilther django.conf.settings.ROOT_URLCONF
, nor 'urls'
, 'urls'
is just the default. The correct value which should indeed be set in settings as EXPORTER_ROUTER_PATH
is the module in which you have imported and configured your router, ie:
from drf_auto_endpoint.router import router
router.registerViewSet(....)
router.register(...)
urlpatterns = [
...
url(r'api/vx/', include(router.urls)),
]
Depending on what structure you decided for your project, this might be in 'urls'
, django.conf.settings.ROOT_URLCONF
, 'any_of_may_apps.api_urls'
Do you have any suggestions on how to make this more clear in the documentation?
This issue is not about documentation; it should be obvious from my text above I know how to change that setting.
This issue is about improving the default.
Don't you think that django.conf.settings.ROOT_URLCONF
is a good default?
Why is urls
a better default?
@jayvdb I'm not saying you don't know how to change the settings, my answer was not directed specifically at you but was trying to answer both people involved in this thread.
I don't think django.conf.settings.ROOT_URLCONF
because I have run into a lot of people who are (and tutorials that advocate) setting their api urls in a separate file. The idea behind a default that "doesn't work" is that people do have to set it to accommodate their own particular setup.
Then it should not have a value at all, and the settings layer of drf-schema-adapter can detect that and raise ImproperlyConfigured with a helpful message.
The default urls should be
django.conf.settings.ROOT_URLCONF
, not 'urls'.