Thursday, August 20, 2015

Re: How do you access the HTTP data in a view derived from the generic View class?

with request.POST.get("foo", "") or request.POST.getlist("foo", [] )


2015-08-20 13:58 GMT-06:00 Daniel Grace <danwgrace@gmail.com>:
Suppose I have a view as follows:

from django.views.generic import View
from django.http import HttpResponse
from braces.views import CsrfExemptMixin

class TestView(CsrfExemptMixin, View):
    def post(self, request, *args, **kwargs):
        # how to access the HTTP data here?
        return HttpResponse(content='some response', status=200)

... and I want to access the data "12345" and "abcde" as in the command:
curl -X POST http://localhost:8000/test/ -d "foo=12345&bar=abcde"

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2ee2e83b-c240-492a-96f8-e3781e269710%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
"La utopía sirve para caminar" Fernando Birri


--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAG%2B5VyMnzU_%2Bo045T-vgs-uvSDK%3D-MiEJ-Wm-j50oAbgvcBYig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment