Using primary key to update via POST request.

21 views
Skip to first unread message

Arpana Mehta

unread,
Jul 20, 2020, 3:44:48 AM7/20/20
to django...@googlegroups.com
Hi,
I have a class with a GET and a POST request. I am sending the data ( with pk of the object ) in my GET request and I want the frontend to use that pk to refer to the exact instance of the model whenever doing any operation.

In my POST request I am only sending the `choice field` value. How do I use the pk received in GET?

Thanks and regards,
Arpana Mehta 

George

unread,
Jul 20, 2020, 5:04:30 PM7/20/20
to Django users
You use request.GET['choice_filed']

Liu Zheng

unread,
Jul 21, 2020, 3:13:54 PM7/21/20
to django...@googlegroups.com
Hi, do you mean in the GET request, the user provides the pk (perhaps in URL) or the server sends to users an object where pk is a field?

If it's the former, then @George's answer is the right one. An example of what you are trying to achieve will be helpful.

Best
Zheng

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/75e78c32-6736-45a0-ab66-9406dc87dc5do%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages