django - How to import dajaxice? -
i'm nooby django , tried many hours simple example of dajaxice running, don't seem find right way files.
i did , redid installation , tried find answers in numerous similar questions on stackoverflow this one , this one.
i put {% dajaxice_js_import %}
in header of myapp_index.html
prints out as:
<script src="/static/dajaxice/dajaxice.core.js" type="text/javascript" charset="utf-8"></script>
but cannot find file:
improperlyconfigured: storage backend of staticfiles finder doesn't have valid location.
and fails:
get /static/dajaxice/dajaxice.core.js http/1.1" 500 59
strangely enough dajax loads:
<script type="text/javascript" src="{% static /static/dajax/jquery.dajax.core.js" %}"></script>
here's folder structure:
myproject ----manage.py ----myproject --------settings.py --------urls.py ----myapp --------ajax.py --------urls.py --------templates ------------myapp_index.html
i haven't understood why need 2 urls.py
files, somehow seems access myapp_index.html
if put
from django.views.generic.simple import direct_to_template
and
url(r'^$', direct_to_template, {'template': 'myapp_index.html'}),
in myapp
's url patterns.
i tried uncountable filenames in
python manage.py findstatic dajaxice.core.js
but somehow doesn't find dajaxice, though dajaxice installed , accepted in settings.py file among installed_apps
.
also python manage.py collectstatic
fails same reason, if understood correctly, don't event have make run long i'm on development server.
i guess have basic misunderstanding of underlying structure. :(
i'm using prepacked latest ubuntu packages:
django: 1.4.5, dajaxice: 0.5.5
thanks in advance hint!
here template file:
{% load static %} {% load dajaxice_templatetags %} <html> <head> <title>my base template</title> {% dajaxice_js_import %} <script type="text/javascript" src="{% static "/static/dajax/jquery.dajax.core.js" %}"></script> <script type="text/javascript"> function my_js_callback(data){ alert(data.message); } dajax; dajaxice; </script> </head> ... <button onclick="dajaxice.myproject.myapp.sayhello(my_js_callback);">click here!</button>
i no django error, page shows, in firebug:
"networkerror: 500 internal server error - http://localhost:8000/static/dajaxice/dajaxice.core.js"
and this:
referenceerror: dajaxice not defined dajaxice;
it seems you've messed urls.conf. should contain like:
url(dajaxice_config.dajaxice_url, include('dajaxice.urls')),
does it?
also, staticfiles_finders
section of settings.py
file should include:
'dajaxice.finders.dajaxicefinder',
Comments
Post a Comment