Skip to content

Commit

Permalink
Auto add URLs for each extension
Browse files Browse the repository at this point in the history
No need to include URLs manually.

Additionally, imports only if urls.py is present. Can be useful when
adding ability to create extensions without URLs (e.g., various
helpers).
  • Loading branch information
Julius committed Sep 20, 2015
1 parent b1d9f1d commit 3eff7e0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions geokey/core/urls.py
Expand Up @@ -11,6 +11,7 @@
url(r'^oauth2/', include('oauth2_provider.urls', namespace='oauth2_provider')),
url(r'^admin/account/', include('allauth.urls')),
url(r'^$', RedirectView.as_view(url='/admin/', permanent=True)),
url(r'^', include('geokey.extensions.urls')),
)

urlpatterns += patterns(
Expand Down
14 changes: 14 additions & 0 deletions geokey/extensions/urls.py
@@ -0,0 +1,14 @@
from django.conf.urls import url, include

from geokey.extensions.base import extensions


urlpatterns = []

for extension in extensions:
try:
urls = '%s.urls' % extension
__import__(urls)
urlpatterns.append(url(r'^', include(urls, namespace=extension)))
except ImportError:
pass

0 comments on commit 3eff7e0

Please sign in to comment.