mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-04 21:58:54 -05:00
added plugin architecture
This commit is contained in:
@@ -14,6 +14,8 @@ Including another URLconf
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
import traceback
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
from django.urls import include, path, re_path
|
||||
@@ -42,3 +44,15 @@ if settings.ENABLE_METRICS:
|
||||
if settings.GUNICORN_MEDIA or settings.DEBUG:
|
||||
urlpatterns += re_path(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}),
|
||||
urlpatterns += re_path(r'^jsreverse.json$', reverse_views.urls_js, name='js_reverse'),
|
||||
|
||||
for p in settings.PLUGINS:
|
||||
try:
|
||||
urlpatterns += path(p['base_url'], include(f'{p["module"]}.urls')),
|
||||
except ModuleNotFoundError as e:
|
||||
if settings.DEBUG:
|
||||
print(e.msg)
|
||||
print(f'ERROR failed loading plugin <{p["name"]}> urls, did you forget creating urls.py in your plugin?')
|
||||
except Exception as e:
|
||||
if settings.DEBUG:
|
||||
print(f'ERROR failed loading urls for plugin <{p["name"]}>')
|
||||
traceback.format_exc()
|
||||
|
||||
Reference in New Issue
Block a user