Question

I've installed dajaxice by this tutorial:

  • Copied folder "dajaxice" (from archive) to project folder.
  • Added all changes to setting.py & urls.py
  • Added next lines to template:

    {% load dajaxice_templatetags %}
    {% dajaxice_js_import %}
    
  • Created ajax.py in the project folder

  • Code from ajax.py:

    from django.utils import simplejson
    from dajaxice.core import dajaxice_functions
    
    @dajaxice_register
    def example1(request):
        return simplejson.dumps({'message': 'hello world'})
    
    dajaxice_functions.register(example1)
    
  • Code from .js file:

    $("#id_submit").click(function(){
        Dajaxice.theproject.example1(callback_example);
        console.log("test clicked");
        return false; });
    
  • When I restart the project in browser at first request I got:

    ImportError at / No module named dajax.core
    Request Method: GET
    Request URL:    http:// 127.0.0.1:8000/
    Django Version: 1.4
    Exception Type: ImportError
    Exception Value:     No module named dajax.core
    Exception Location: C:\Python27\lib\importlib\__init__.py in import_module, line 37
    Python Executable:  C:\Python27\python.exe
    Python Version: 2.7.3
    Python Path:     ['E:\\Projects\\py\\sites\\theproject',  'C:\\Windows\\system32\\python27.zip',  'C:\\Python27\\DLLs',  'C:\\Python27\\lib',  'C:\\Python27\\lib\\plat-win',  'C:\\Python27\\lib\\lib-tk',  'C:\\Python27',  'C:\\Python27\\lib\\site-packages',  'C:\\Python27\\lib\\site-packages\\PIL']
    Server time:    Fri, 3 Aug 2012 14:50:03 +0300 
    

Any ideas?

Was it helpful?

Solution

load ajax.py in init.py(of main app)

OTHER TIPS

Dajaxice is updating all the time. Make sure you have downloaded and installed the correct version of Dajax for the document you are reading. In your error message, it says, "No module named dajax.core", which is probably because you are using the wrong version.

And the current version of Dajaxice and Dajax can be found here:

https://pypi.python.org/pypi/django-dajax

https://pypi.python.org/pypi/django-dajaxice/0.5.5

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top