Created
July 8, 2013 07:38
-
-
Save ir4y/5946909 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def resouce_autodiscover(): | |
from django.conf import settings | |
from django.utils.importlib import import_module | |
v1_api = Api(api_name='v1') | |
for app in settings.INSTALLED_APPS: | |
try: | |
resorce_api = import_module('%s.api' % app) | |
for resource_klass_name in resorce_api.__all__: | |
resource_klass = getattr(resorce_api, resource_klass_name) | |
v1_api.register(resource_klass()) | |
except: | |
continue | |
return v1_api | |
v1_api = resouce_autodiscover() | |
urlpatterns = patterns( | |
'', | |
url(r'^api/', include(v1_api.urls)), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment