Why does my Django request.method is 'GET' not 'POST'?

django, django-forms, python

Solution

In my case I was missing a "/" at the end of action in the HTML Template, while posting.

Problem

I met this strange problem when doing a pre-populated form. In my template, the form method is clearly stated as `POST`: ``` <form class="form-horizontal" role="form" action="" method="post" enctype="multipart/form-data">{% csrf_token %} ``` But in my view function, the request.method turns out to be `GET`. Below is my view function: ``` def editProfile(request,template_name): theprofile = request.user.profile print theprofile.fullname notificationMSG = '' print request.method if request.method == 'POST': form = UserProfileForm(request.POST,request.FILES, instance=theprofile) if form.is_valid(): form.save() notificationMSG = "success!" else: form = UserProfileForm() print "error" dic = {'form':form, 'notificationMSG':notificationMSG} return render_to_response(template_name, dic, context_instance=RequestContext(request)) ``` When I run it, it prints out `GET`. Anyone met this odd before?

Original source