Thursday, July 27, 2017

Re: Getting response code 302 instead of 200 while testing a url


The problem here is that my test cased passed for the first 2 functions i.e. "test_post_list" and "test_post_create" but now working for other two test functions i.e "test_post_update" and "test_post_delete". What might be the problem ?

The setup function that i made is supposed to create a object of model named "Post", then what might be the problem ?

Actually,  that's probably a valid/correct response. In general, when sending a POST request, a redirect (the 302) is returned by a view to another landing page (where you would then receive a 200), where the successful message is displayed to the user. This is done to prevent the user from submitting the form multiple times by clicking the back button (the browser presents the "are you sure you want to send this data again?" message). 

The generic create/update views included with Django have this behavior. 

Without seeing the views, it's hard to tell for sure. 

-James 

--
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/CA%2Be%2BciWSCD9hK_cViYgFJuFOXFvC%2Bp1Wxz1oMFuHOySvhZYnAw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment