Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError - module 'urls' has no attribute 'urls' #32

Closed
poswald opened this issue Dec 21, 2015 · 5 comments
Closed

AttributeError - module 'urls' has no attribute 'urls' #32

poswald opened this issue Dec 21, 2015 · 5 comments
Labels

Comments

@poswald
Copy link

poswald commented Dec 21, 2015

My understanding is that there are two common settings of ROOT_URLCONF people use. One is the default ROOT_URLCONF = '' value, and the second is ROOT_URLCONF = 'urls'. This project seems to fail if you use the latter (or at least it did for me). Changing that line to self.get_all_view_names(root_urlconf.urlpatterns) worked but it would be best to fix in the project.

The root urlconf can also be overridden at runtime via middleware so I think this urls module loading should perhaps be moved into the get_endpoints method or the value of that setting should be passed into the ApiDocumentation object on init.

Nice project BTW. :-)

@manosim manosim added the bug label Dec 21, 2015
@manosim
Copy link
Owner

manosim commented Dec 21, 2015

Hi @poswald! I remember having this issue while I was writing some tests for the package. So I was thinking that a check like the one below would make sense?

    if hasattr(root_urlconf, 'urls'):
        self.get_all_view_names(root_urlconf.urls.urlpatterns)
    else:
        self.get_all_view_names(root_urlconf.urlpatterns)

I can confirm that it works when ROOT_URLCONF = 'project.urls'
Can you check if it works with your project?

Thank you!

@poswald
Copy link
Author

poswald commented Dec 21, 2015

Yes it does. I think adding a check like that is fine for now. I do suggest looking into supporting runtime-specified configurations though as I think people use them to do things like having different url schemes for different types of users.

@manosim
Copy link
Owner

manosim commented Dec 21, 2015

Yeap let's go with that check for now 👍
I've just published 0.0.5 to pypi so it should work now! Let me know if it does not!

@manosim manosim closed this as completed Dec 21, 2015
@poswald
Copy link
Author

poswald commented Dec 22, 2015

It works, you just need to push the changelog. :-) Thanks.

@manosim
Copy link
Owner

manosim commented Dec 22, 2015

Done! 😄 http://drfdocs.com/docs/changelog/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants