Skip to content

Commit 1caf6d3

Browse files
author
Mark Gibbs
committed
Add dash component files to django staticfiles collection, and a redirection link also
1 parent e44daad commit 1caf6d3

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ coverage.xml
5454
*.log
5555
local_settings.py
5656
*/db.sqlite3
57+
demo/static/*
5758

5859
# Flask stuff:
5960
instance/

demo/demo/settings.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,13 @@
120120
# https://docs.djangoproject.com/en/2.0/howto/static-files/
121121

122122
STATIC_URL = '/static/'
123+
STATIC_ROOT = os.path.join(BASE_DIR,'static')
124+
125+
STATICFILES_DIRS = [
126+
]
127+
128+
import dash_core_components as dcc
129+
_rname = os.path.join(os.path.dirname(dcc.__file__),'..')
130+
for dash_module_name in ['dash_core_components','dash_html_components','dash_renderer',]:
131+
STATICFILES_DIRS.append( ("dash/%s"%dash_module_name, os.path.join(_rname,dash_module_name)) )
132+

django_plotly_dash/dash_wrapper.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ def __init__(self, base_pathname=None, replacements = None, ndid=None, expanded_
153153
super(NotDash, self).__init__(**kwargs)
154154

155155
self.css.config.serve_locally = True
156+
#self.css.config.serve_locally = False
157+
158+
self.scripts.config.serve_locally = self.css.config.serve_locally
156159

157160
self._adjust_id = False
158161
self._dash_dispatch = not expanded_callbacks

django_plotly_dash/views.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,11 @@ def main_view(request, id, stateless=False, **kwargs):
6262
return HttpResponse(resp)
6363

6464
def component_suites(request, resource=None, component=None, **kwargs):
65-
print("Blagging component suites")
66-
print(kwargs)
6765

6866
eBig = request.GET.urlencode()
6967
if len(eBig) > 0:
70-
redone_url = "/STATIC/%s/%s?%s" %(component, resource, eBig)
68+
redone_url = "/static/dash/%s/%s?%s" %(component, resource, eBig)
7169
else:
72-
redone_url = "/STATIC/%s/%s" %(component, resource)
70+
redone_url = "/static/dash/%s/%s" %(component, resource)
7371

74-
print(redone_url)
75-
76-
return HttpResponseRedirect(redirect_to="/static/someth")
72+
return HttpResponseRedirect(redirect_to=redone_url)

prepare_demo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ source env/bin/activate
44
cd demo
55
./manage.py migrate
66
./manage.py shell < configdb.py # Add a superuser if needed
7+
./manage.py collectstatic -i "*.py" -i "*.pyc" --noinput --link
78
./manage.py runserver

0 commit comments

Comments
 (0)