Reputation: 812
I'm trying to get the following to work: http://django-rest-framework.org/examples/views.html in my own django app. When I do a GET it returns 200 and provides the correct response. However, when I attempt a POST all I get is a 500 error. I am completely stumped, it seems so simple I can't figure out what I'm doing wrong.
urls.py:
from django.conf.urls.defaults import patterns, url
from test.testapp.views import ws_list
urlpatterns = patterns('test.testapp.views',
...
url(r'^ws/List/$', ws_list.as_view()),
url(r'^ws/List/(?P<pk>\d+)/$', ws_list.as_view()),
)
views.py:
...
from djangorestframework.views import View
class ws_list(View):
def get(self, request, pk=0):
if pk == 0:
rtStr = 'GET the whole list'
else:
rtStr ="GET request to List %s" % pk
return rtStr
def post(self, request, pk=0):
return "POST request to List %s, with content: %s" % (pk, repr(self.CONTENT))
I've also tried adding in the forms.py for validation but, like I suspected, it didn't do anything. It seems that this should be so easy, I just can't understand why it wont work...
Upvotes: 0
Views: 1536
Reputation: 812
Forgot to add the trialing / to the web service call...turning on debugging helps!
Upvotes: 1