On 09/20/2011 05:53 PM, DrBloodmoney wrote:
On Tue, Sep 20, 2011 at 11:46 AM, Fabio Natali<fa...@fnstudio.it>  wrote:
Hi everybody!

I have a very simple view which is supposed to print out GET or POST,
depending which has been used to send data. The problem is I always get
"GET" even when sending data via POST.

### views.py:
def method(request):
    return HttpResponse(request.method)

### urls.py:
(r'^method/$', method)

### php script to send data to the Django page:
<form method="post" action="http://192.168.0.2:8000/method/";>
  <input type="text" id="firstname">
  <input type="submit" value="Send">
</form>

I am running Django version 1.2.5, development server.

Am I missing something? Any hint?

Thanks, Fabio.

--
Fabio Natali FNstudio

I'm not 100% sure, but since you aren't including the
csrfmiddlewaretoken in the post data, I would expect it to 403 if you
aren't exempting the view from CSRF protection [1].

[1] https://docs.djangoproject.com/en/1.3/ref/contrib/csrf/

Hi DrBloodmoney, thanks for your kind reply.

I've modified my view as follows:

### views.py:
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def method(request):
     return HttpResponse(request.method)

However everything behaves the same way, I still have "GET" erroneously detected.

Do you have any other hint on how to investigate?

Thanks, Fabio.

--
Fabio Natali FNstudio

--
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