if i want to check whether i am receiving a POST request, do i use request.POST or request.method=='POST'? The second one is used to check for empty data submitted with the POST request so it wouldn't necessarily tell me whether it's a POST request, right?
it could still return false if there is no data?
ubernostrum
request.method tells you what the HTTP request method was. If you're trying to find out if the HTTP request method was POST, then you should be checking request.method :)
frenchiie
so why do we use request.POST
or why is it there for
ubernostrum
request.POST holds the data submitted in the request.
(if it was a POST)
frenchiie
ah
ubernostrum
request.method is a string, request.POST is a dictionary.
request.GET is also a dictionary :)
Andy80_ has quit
frenchiie
so what would happen if i did request.POST to check for a POST request? If it's a POST request and there is data it would return true but if it's a POST request and there is no data it would return false? Or does it just return null if it's empty?
if request.POST:
and would it give an error if you used request.POST when it's a GET request?
Hairy has quit
ubernostrum
Off the top of my head I don't know. I just know that you should instead do "if request.method == 'POST'"
And then access things you care about from request.POST if that check passes.
frenchiie
okay thanks
:D
rew1red has quit
ubernostrum
Looks like if it's empty it's boolean False.
rew1red joined the channel
So if the method was POST but no data, doing "if request.POST" will not work.
rew1red has quit
rew1red joined the channel
rew1red has quit
ubuntu_aze has quit
rew1red joined the channel
ycon_ joined the channel
otrenav joined the channel
Knyght
having some factory boy issues... think I'm using django_get_create properly but I'm still getting unique constraints violated: https://dpaste.de/5rU6
rew1red has quit
zeograd has quit
zeograd joined the channel
tiagoboldt has quit
rew1red joined the channel
rew1red has quit
rew1red joined the channel
or maybe I fugured it out
rew1red has quit
rew1red joined the channel
abara joined the channel
abara
hey guys! there is an option to set a another template folder to CBS besides the prefix?