python - Django - static folder mapping in urls.py -
i have following files structure in django app
|-myapp |---static |-----adminapp |-----clientapp |-----commonapp |-----css |-----fonts |-----js |---templates |-----administration |-------index.html |-----client |-------index.html it's because want build 2 angular apps, 1 users (static/clientapp) , 1 admin (static/adminapp).
templates/administration/index.html , templates/client/index.html similar , contains code like:
<head> <script src="static/js/angular.js"></script> <script src="static/adminapp/app.js"></script> </head> <body ng-app="adminapp"></body> links admin , client apps should be:
http://example.com/administration/ http://example.com/client/ the question entry should add urls.py let both angular apps access same static folder.
it must like:
url(r'^administration/static/$', static_root), url(r'^client/static/$', static_root) but i'm django newbie , don't know how define correctly.
in production should not let django handle static files, should in nginx/appache config set correct paths administation/static/ , client/static/.
for dev purposes, add this:
if settings.debug: urlpatterns += [ url(r'^administation/static/(?p<path>.*)$', ' django.views.static.serve', {'document_root': settings.admin_static_root}), url(r'^client/static/(?p<path>.*)$', ' django.views.static.serve', {'document_root': settings.client_static_root}), ] then have define admin_static_root , client_static_root in settings.
Comments
Post a Comment