mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-02-02 20:54:42 +03:00
Fix import errors
This commit is contained in:
parent
30e3775b8b
commit
8845c0be88
|
@ -431,5 +431,12 @@ except ImportError:
|
|||
# OAuth 2 support is optional
|
||||
try:
|
||||
import provider.oauth2 as oauth2_provider
|
||||
|
||||
# Hack to fix submodule import issues
|
||||
submodules = ['backends', 'forms','managers','models','urls','views']
|
||||
for s in submodules:
|
||||
mod = __import__('provider.oauth2.%s.*' % s)
|
||||
setattr(oauth2_provider, s, mod)
|
||||
|
||||
except ImportError:
|
||||
oauth2_provider = None
|
||||
|
|
|
@ -106,7 +106,7 @@ try:
|
|||
'provider',
|
||||
'provider.oauth2',
|
||||
)
|
||||
except ImportError, inst:
|
||||
except ImportError:
|
||||
import logging
|
||||
logging.warning("django-oauth2-provider is not install, some tests will be skipped")
|
||||
|
||||
|
|
|
@ -46,9 +46,13 @@ urlpatterns = patterns('',
|
|||
(r'^basic/$', MockView.as_view(authentication_classes=[BasicAuthentication])),
|
||||
(r'^token/$', MockView.as_view(authentication_classes=[TokenAuthentication])),
|
||||
(r'^auth-token/$', 'rest_framework.authtoken.views.obtain_auth_token'),
|
||||
)
|
||||
|
||||
if oauth2_provider is not None:
|
||||
urlpatterns += patterns('',
|
||||
url(r'^oauth2/', include('provider.oauth2.urls', namespace = 'oauth2')),
|
||||
url(r'^oauth2-test/$', MockView.as_view(authentication_classes=[OAuth2Authentication])),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class BasicAuthTests(TestCase):
|
||||
|
|
Loading…
Reference in New Issue
Block a user