jorgebastida / django-dajax

Easy to use library to create asynchronous presentation logic with django and dajaxice
http://dajaxproject.com/
BSD 3-Clause "New" or "Revised" License
346 stars 99 forks source link

Internal Server Error 500 | TypeError | Multiply() takes exactly 3 arguments (1 given) #86

Open roperi opened 9 years ago

roperi commented 9 years ago

Hi!

It seems to me dajaxice is great! But I've spent last two days trying to make the dajaxice example to work (Opera, Firefox). I have searched everywhere in the intertubes to no avail. It seems everyone has an idea/solution how to solve this problem but no one has come up with a straightforward answer/solution.

Versions Dajaxice - 0.9.2 Dajax - 0.7 Django 1.7 Python 3.2

Settings.py INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'dajax', 'dajaxice',

TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', 'django.template.loaders.eggs.Loader', # Uncomment? See http://django-dajaxice.readthedocs.org/en/latest/installation.html#installing-dajaxice ) TEMPLATE_CONTEXT_PROCESSORS = ( 'django.contrib.auth.context_processors.auth', 'django.core.context_processors.debug', 'django.core.context_processors.i18n', 'django.core.context_processors.media', 'django.core.context_processors.static', 'django.core.context_processors.request', 'django.contrib.messages.context_processors.messages' )

urls.py

url(dajaxice_config.dajaxice_url, include('dajaxice.urls')),
url(r'^$',TemplateView.as_view(template_name='test_3/ajax_test.html'),name='ajaxhome'),

urlpatterns += staticfiles_urlpatterns()

Javascript function calculate(){Dajaxice.test_3.multiply(Dajax.process,{'a':$('#a').val(),'b':$('#b').val()})}

Form: x =

<button value="Multiply!" onclick="calculate();">Click here!</button>   

Ajax.py @dajaxice_register def multiply(request, a, b): dajax = Dajax() result = int(a) * int(b) dajax.assign('#result','value',str(result)) return dajax.json()

ERROR Traceback: File "/usr/local/lib/python3.2/dist-packages/django/core/handlers/base.py" in get_response

  1. response = wrapped_callback(request, _callback_args, *_callback_kwargs) File "/usr/local/lib/python3.2/dist-packages/django/views/generic/base.py" in view
  2. return self.dispatch(request, _args, *_kwargs) File "/usr/local/lib/python3.2/dist-packages/dajaxice/views.py" in dispatch
  3. response = function.call(request, **data) File "/usr/local/lib/python3.2/dist-packages/dajaxice/core/Dajaxice.py" in call
  4. return self.function(_args, *_kwargs)

Exception Type: TypeError at /dajaxice/test_3.multiply/ Exception Value: multiply() takes exactly 3 arguments (1 given)

Request information: Get: No GET data Post:: argv = '{"a":"5","b":"6"}'

Please help!

Thanks in advance!