Saturday, December 23, 2017

Django foms problems .. please help me

Hi Everyone,

I am trying to pass current user  as request.user.

It handles properly in forms and i am getting choice filed with the help of it.

But, when i tried to read the data throough post method. it is going to form invalid section..

Please help me ASAP.

views.py
def instancecreate(request):
if request.method=='POST':
print('POST FORM @@@@@@@@@')
form=InstanceCreationForm(request.user,request.POST)

if form.is_valid():
images = request.POST['name']
print('you handled post data')
print(images)
return HttpResponse(images)
else:
print('NOT a Valid Form !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
form=InstanceCreationForm(request.user)
return render(request, 'url/User/cinstance.html', {'form': form})


else:

form=InstanceCreationForm(request.user)
return render(request, 'url/User/cinstance.html', {'form': form})

--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/138500c0-6721-4ba8-ad32-2a51816ef25d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment