Reputation: 417
import in HTML:
<script src="/media/js/jquery-2.0.2.js"></script>
<script src="jquery.dajax.core.js"></script>
<script type="text/javascript">
function oneri()
{
Dajaxice.rezervationApp.oneri(Dajax.process)
}
</script>
I use:
<div class="span6"> <a href="#adviceModal" class="btn" role="button" onClick="oneri()" data-toggle="modal">Öneri Al</a></div>
in ajax.py
from django.template.loader import render_to_string
from dajaxice.decorators import dajaxice_register
from django.shortcuts import render
from rezervationApp.models import RoomType, Room, Market, Profile, Reservation
@dajaxice_register
def oneri(request, word):
dajax = Dajax()
p = Profile.objects.get(firstname__contains=word)
dajax.assign('#advice','innerHTML', p)
return dajax.json()
Fully error:
ImportError at /
No module named 'Dajaxice'
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.5.1
Exception Type: ImportError
Exception Value:
No module named 'Dajaxice'
Exception Location: C:\Python33\lib\site-packages\dajaxice\core\__init__.py in <module>, line 3
But, always same error. I configured other file as dajax tutorial. Do you have any idea?
Upvotes: 1
Views: 2883
Reputation: 11
Just install the dajax package using the below command.
pip3 install dajax pip3 install django-dajaxice (If the Python version is 3 or more than that)
pip install dajax
Upvotes: 0
Reputation: 116
If that is your generated HTML then there's where the problem lies. If you followed the Dajaxice set up tutorial on their documentation, you probably used {% load dajaxice_templatetags %}
{% dajaxice_js_import %}
in the head of your templates. This is supposed to generate a static dajaxice.core.js file where your static folder is and show you something like <script charset="utf-8" type="text/javascript" src="/static/dajaxice/dajaxice.core.js">
in your generated HTML.
If you have followed the installation steps for both Dasjax and Dajaxice exactly then define a STATIC_ROOT setting in your settings.py as the location of your static root folder (relative to the settings.py file) and then run python manage.py collectstatic
this should give you 200 and eventually 304 responses for the Dajaxice javascript file and your app should run just fine.
Upvotes: -1
Reputation: 674
The problem is in difference between py2 and py3. Py3 allows only explicit relative imports. It works when you add a dot.
from .Dajaxice import Dajaxice, dajaxice_autodiscover
Upvotes: 4
Reputation: 424
If I remember correctly the Dajaxice tutorial leaves out the part where you actually have to install Dajaxice...
If you haven't already you should try pip install django-dajaxice
Upvotes: 3