JChao
JChao

Reputation: 2309

How to pass multiple queries in url to Django

my urls.py setting is

path('somepath', views.somefunc.as_view(), name='SomeFunc')

SomeFunc takes POST and is supposed to take some query commands like

localhost:8000/path/to/somepath?a=f&b=g

When I print out the request itself, it seems like it's only reading POST /path/to/somepath?a=f and I cannot get anything from request.POST

How do I read both a and b?

This is Django2.0 by the way

EDIT:

I feel like I have some misunderstanding of the fundamental of django or even REST in general.

When I try to do a requests.post in python as I pass in the queries in the url, somehow those queries show up in request.GET on the django side.

My understanding has been that requests.post posts the data set in queries to django, so the queryset should show up in POST instead of GET

This seems like it's not the case. I wonder what I'm missing here.

using request.GET fixes everything..... but it's not really a fix so to speak

Upvotes: 0

Views: 151

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599450

That's not POST data, it's GET. You can get it from request.GET.

Upvotes: 1

Related Questions