Я встретил эту странную проблему, когда делаю предварительно заполненную форму. В моем шаблоне, метод формы четко указано, как POST
:Почему мой Django request.method «GET» не «POST»?
<form class="form-horizontal" role="form" action="" method="post" enctype="multipart/form-data">{% csrf_token %}
Но в моей функции зрения, request.method оказывается GET
.
Ниже мой взгляд функция:
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))
Когда я запускаю его, он печатает GET
. Кто-нибудь встречал это раньше?
, когда вы отправляете форму, вы не используете какой-либо javascript? – Hoopdady