On Fri, Oct 7, 2011 at 6:31 AM, bino oetomo <b...@indoakses-online.com> wrote:
>
> Dear All ...
>
> Reff, samuraisam's django-json-rpc is at :
> https://github.com/samuraisam/django-json-rpc#readme
>
> I try to implement that solution to my "Poll" app .. hope that it'll be
> accessible via simple HTTP-GET.
>
> What I've done :
> ----Below is mypoll/urls.py:
> from django.conf.urls.defaults import *
> from jsonrpc import jsonrpc_site
> import mypoll.poll.views
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
>    url(r'^json/browse/$', 'jsonrpc.views.browse', name="jsonrpc_browser"),
>    url(r'^json/$', jsonrpc_site.dispatch, name='jsonrpc_mountpoint'),
>    (r'^json/(?P<method>[a-zA-Z0-9.-_]+)$', jsonrpc_site.dispatch),
>    (r'^admin/', include(admin.site.urls)),
> )
> ----Below is mypoll/poll/views.py:
> from jsonrpc import jsonrpc_method
> from poll.models import *
>
> @jsonrpc_method('poll.add', authenticated=True, safe=True)
> def add_poll(request, question):
>  p = Poll(question=question, pub_date=datetime.datetime.now())
>  p.save()
>  return p.__dict__
>
> ---Below is INSTALLED_APPS of mypoll/settings.py
> INSTALLED_APPS = (
>    'django.contrib.auth',
>    'django.contrib.contenttypes',
>    'django.contrib.sessions',
>    'django.contrib.sites',
>    'django.contrib.messages',
>    'django.contrib.admin',
>    'poll',
>    'jsonrpc',
> )
> ==========================
> Next I test it with :
> http://127.0.0.1:8000/jsonrpc/poll.add?username=bino&;password=123&question=TryJson
>
> The result is :
> -----START------
> Using the URLconf defined in mypoll.urls, Django tried these URL patterns,
> in this order:
>
>   1. ^json/browse/$ [name='jsonrpc_browser']
>   2. ^json/$ [name='jsonrpc_mountpoint']
>   3. ^json/(?P<method>[a-zA-Z0-9.-_]+)$
>   4. ^admin/
>
> The current URL, jsonrpc/poll.add, didn't match any of these.
> -----STOP-------
>
> Kindly please give me your enlightment to fix this problem
>
> Sincerely
> -bino-
>

The URL you are trying to go to does not match up with the URL you
configured in urls.py (nor does it match up with the docs you linked
to). Your tested URL starts with 'jsonrpc/', your urls.py says
'json/'.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to