Are you sending the JSON document as the body of your POST request? If
so, you won't see anything in request.POST, because it's only populated
for requests using application/x-www-form-urlencoded. You probably want
to use request.body
(https://docs.djangoproject.com/en/1.5/ref/request-response/#django.http.HttpRequest.body)
to get at the raw JSON. To get it as a dictionary object in Python,
import the json module, then do:

>>> data = json.loads(request.body)

_Nik

On 7/2/2013 2:28 PM, Lucas Simon wrote:
> 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/
>     <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 <http://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 <javascript:>.
>>     To post to this group, send email to django...@googlegroups.com
>>     <javascript:>.
>>     Visit this group at http://groups.google.com/group/django-users
>>     <http://groups.google.com/group/django-users>.
>>     For more options, visit https://groups.google.com/groups/opt_out
>>     <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+unsubscr...@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.
>  
>  

-- 
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+unsubscr...@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.


Reply via email to