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 7640933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:47:50+00:00 2026-05-31T08:47:50+00:00

I have a view that allows to add tags dynamically with an ajax request.

  • 0

I have a view that allows to add tags dynamically with an ajax request. It looks like this:

@require_POST
@login_required
def addtag(request):
   """
   a view to create a new tag in the tag database
   """
   some logic here

This is what my url.py looks like:

urlpatterns = patterns('',
                       url(r'^addtag/$',addtag, name='addtag'),
                      )

And my test is doing that:

def test_addtag(self):
    url='^addtag/$'

    response = self.client.post(url,{'addtag':'"new tag"'})
    self.assertEqual(response.status_code,401)

I expected the returned status code to be a 401, since the testclient is not logged in. So the first decorator, checking if the request is a post is being passed happily. Then i expected the login_required decorator to return a 401, but it didn’t:

AssertionError: 302 != 401

First i thought the login_required decorator would be redirecting to some login page. Checked that, i do not have a settings.LOGIN_REDIRECT_URL specified. So what is login_required doing in this case?

  • 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-31T08:47:51+00:00Added an answer on May 31, 2026 at 8:47 am

    @login_required redirects to the login page if the user is not logged in — hence the view returns 302 in such a case. (If you did not set LOGIN_REDIRECT_URL it uses a default value.)

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

Sidebar

Related Questions

I have a view function that allows a user to Add / Edit /
I have a view controller that allows users to add an nsstring to an
I have a webform that allows users to dynamically add 'sections' (which are divs
We have FireSymfony that allows one to view the Symfony, PHP variables in a
I have a web application that allows a user to view family members. When
I have an online store. A products page that allows the user to view
I have a view that allows the user to select some data : some
I want to add a view to my application that allows the user to
Trying to create a page that allows users to add edit and view a
I have a view for my customer object that allows him to choose a

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.