marcgibbons / django-rest-framework-docs

An inventory tool for Django Rest Framework v2 API endpoints
BSD 2-Clause "Simplified" License
95 stars 34 forks source link

AtrributeError module' object has no attribute 'urls' #6

Closed poswald closed 11 years ago

poswald commented 11 years ago

Was looking into this to try out tomchristie/django-rest-framework/pull/616 and it doesn't wrok in my project. I think the problem comes from the fact that the ROOT_URLCONF setting may or may not be the place you want to import from. See the django docs for info. Could be something totally unrelated though.

In this project I have ROOT_URLCONF='urls' but I get:

Exception Type: AttributeError
Exception Value:    'module' object has no attribute 'urls'

If I change docs.py to:

    urls = __import__(settings.ROOT_URLCONF)
    patterns = urls.urlpatterns # <- changed

…it works (but all of the later calls to class_instance = pattern.callback.cls_instance raise an exception and I get a blank page.)

marcgibbons commented 11 years ago

Thanks for bringing this up. In the projects I've plugged this in, the ROOT_URLCONF is pointed to the full application path. I believe a pull request was make this auto-detection feature more versatile. I'll look into it in the next few days. Many thanks!