GET Formset returns 302 instead of 200 (django) -


I have used inlineformatet, the idea method is as follows:

  @login_required def Patron_edit_phone (requests, * args, ** kwargs): Protector = request.user PhoneNumberFormSet = inlineformset_factory (Guardian, PhoneNumber, Extra = 1, out = "Type", can_order = true) if request.method == "Post": formset = PhoneNumberFormSet (request.POST, request.FILES, Example = Protector) if formset.is_valid (): formset.save () messages.success (request, _ (U "Votre information de Numa © ro de Ta © là © phone one Bien à © ti © mise à jour ")) Other: formset = PhoneNumberFormSet (Example = Protector) and The direct_template (request, 'accounts / patron_phone_edit.html', extra_context = {'formset': formset, 'patron': patron})   

I tested the "post" method for inline format I have been successful in doing this. Here is the code

  def test_patron_phone_edit (self):. Self.client.login (username ='alex.wg@e.com ', password =' ​​Alex ') response = self.client.post (reverse (' patron_edit_phone '), {' phone- TOTAL_FORMS ': u'1' , 'Phone-INITIAL_FORMS': U ',' Phone: MAX_NUM_FORMS ': U', 'Phone-0-ID': '1', 'Phone-0-Protector': '1', 'Phone-0-Number' : "11111111", 'Phone-0-Delete': U ''}) self.assertEquals (response.status_code, 200) patron = patron.objects.get (email='alex.wg@e.com ') patron For phones in Phone.all (): if phone.id == 1: self.assertEquals (phone.number, "11111111") and: pass   

with receiving the method Have tried the following:

  def test_patron_phone_get_form (self): self.client.login (usernamer = 'alex.wg @ E.com ', password =' ​​Alex ') response = self.client.get (reverse (' patron_edit_phone ')) self.assertEquals (response.status_code, 200)   

but this work Instead of getting a status_code = 200, why do I get a status_code = 302? Maybe I need to specify the total forms for the GET method?

Any help is highly appreciated! Thanks!

If more information is needed, leave a comment, then I will paste it, the necessary information.

You must have a typo in the login function Usernamer user name that is sending you a 302 redirect Sends you to the login page.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -