Tuesday, July 2, 2013

Re: Class Based View returning blank post data

How does this fit in with a large JSON document? There should be a way to parse all of this arbitrary data, and filter out the stuff that fits into a form

On Tuesday, July 2, 2013 3:08:10 PM UTC-6, Nikolas Stevenson-Molnar wrote:
That's the expected output, since your URL pattern to that view doesn't contain any arguments. Take a look at the examples in https://docs.djangoproject.com/en/1.5/topics/http/urls/ ... the URL patterns with groups will have the matched values passed to the view function as arguments (named groups are passed as kwargs).

Likewise, unless you submitted POST data with your request, you should expect request.POST to be empty.

_Nik

On 7/2/2013 2:03 PM, Lucas Simon wrote:
Hi,

I think I found a bug and was not sure where to post it other than here. I have created a view defined as follows

from django.http import HttpResponse, Http404
from django.views.generic.base import View

class TestView(View):
def post(self, request, *args, **kwargs):
print "*******************************"
print request.POST
print args
print kwargs
print "*******************************"
return HttpResponse("hello, world")

When I make a post request with CURL or advanced rest framework, the console outputs blank data,

*******************************
<QueryDict: {}>
()
{}
*******************************
[02/Jul/2013 15:00:39] "POST /blog/ HTTP/1.1" 200 12

Also, it is probably worth mentioning that I commented out the csrf middleware. My two urls.py files are define as

from django.conf.urls import patterns, include, url

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
url(r'^blog/', include('blog.urls')),
    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # url(r'^admin/', include(admin.site.urls)),
)

and as follows for blog.urls.py

from django.conf.urls import patterns, include, url
from .views import * 

urlpatterns = patterns('',
    url(r'^$', TestView.as_view()),
)
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment