Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6551771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:22:45+00:00 2026-05-25T12:22:45+00:00

I have used the inlineformset, the views method is as follows: @login_required def patron_edit_phone(request,

  • 0

I have used the inlineformset, the views method is as follows:

@login_required
def patron_edit_phone(request, *args, **kwargs):
    patron = request.user
    PhoneNumberFormSet = inlineformset_factory(Patron, PhoneNumber, extra=1, exclude="kind",can_order=True)
    if request.method == "POST":
        formset = PhoneNumberFormSet(request.POST, request.FILES, instance=patron)
        if formset.is_valid(): 
            formset.save()
            messages.success(request, _(u"Votre information de numéro de téléphone a bien été mise à jour"))
    else:
        formset = PhoneNumberFormSet(instance=patron)

    return direct_to_template(request, 'accounts/patron_phone_edit.html', extra_context={'formset': formset, 'patron': patron })

I have succeeded to test the “post” method for the inlineformset. 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'), {
            'phones-TOTAL_FORMS': u'1',
            'phones-INITIAL_FORMS': u'',
            'phones-MAX_NUM_FORMS': u'',

            'phones-0-id' : '1',
            'phones-0-patron' : '1',
            'phones-0-number' : "11111111", 
            'phones-0-DELETE' : u''
    })
    self.assertEquals(response.status_code, 200)
    patron = Patron.objects.get(email='alex.wg@e.com')
    for phone in patron.phones.all():
        if phone.id == 1:
            self.assertEquals(phone.number, "11111111")
        else:
            pass  

I have tried the following with the get method:

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 doesn’t work. Instead of getting a status_code=200, I get a status_code=302. Why? Perhaps 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 the needed information.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T12:22:46+00:00Added an answer on May 25, 2026 at 12:22 pm

    You have a typo in the login function. usernamer should be username. You’re getting a 302 redirect sending you to the login page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I have the following form: class DesignItemForm (forms.ModelForm): def __init__(self, *args, **kwargs): super(DesignItemForm,
I have used a list view in view flipper, I want that when user
I have used BaseAdapter for grid view, in getView method of BaseAdapter I am
I have used the hasClass method before but I have a scenario where is
I have used the silverlight control in CRM 2011.It also published on form but
We have used Shibboleth to authenticate users. It works great. The issue is that
I have used some jquery components in my web site, Suddenly i'm getting an
I have used a plugin that uses prototype js, it's working fine but the
I have used NSSets many times in my apps, but I have never created
I have used this website for testing http://www.webpagetest.org and among some suggestions for optimization

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.