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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:48:49+00:00 2026-06-04T11:48:49+00:00

I have login_required decorator as follows: def login_required(function): Decorator to check Logged in users.

  • 0

I have login_required decorator as follows:

def login_required(function):
  """ Decorator to check Logged in users."""
  def check_login(self, *args, **kwargs):
    if not self.auth.get_user_by_session():
      self.redirect('/_ah/login_required')
    else:
      return function(self, *args, **kwargs)
  return check_login

Now I have a Page (which is rendered by a seperate Handler) where I have an option for users to upload image which can be viewed both by guests and users. As soon as the form is posted it is handled by another Handler which uses the @login_required decorator.

What I want to achieve is passing a continue_url variable that I can use in the check_login function while redirecting so that the user gets redirected back to the same page after logging in.

  • 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-06-04T11:48:51+00:00Added an answer on June 4, 2026 at 11:48 am

    So basically, it sounds like you want to pass an argument to the decorator when you use it. Python does support this. The basic idea is that @decorated(argument) def foo(...) is equivalent to def foo(...); foo = decorated(argument)(foo).

    So you need to make decorated be something such that decorated(argument) can decorate foo. There are several recipes for this. Here’s one – make decorated a class with a __call__ method, so that decorated(argument) is a callable object that stores argument and uses it when called:

    class decorator(object):
        def __init__(argument):
            self.argument = argument
    
        def __call__(self, wrapped):
            def wrapper(args_for_wrapped):
                do_something_with(self.argument)
                wrapped(args_for_wrapped)
                whatever_else_this_needs_to_do()
            return wrapper
    

    This can also be achieved with a plain function (and an additional level of nesting), with tricks involving functools.partial etc.

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

Sidebar

Related Questions

I have several views with @login_required decorator. And I'm going to use django.core.urlresolvers.reverse() function
I have used the inlineformset, the views method is as follows: @login_required def patron_edit_phone(request,
I have a view function: @login_required def myview(): # do something # respond something
We are using the @login_required decorator so that users see a login page if
I'm working on some legacy Django code. I have two nearly-identical views: @login_required def
I have a Django application which liberally uses django.contrib.auth.decorators.login_required() and also django.views.decorators.http.require_http_methods() . The
I successfully with webapp2 can authenticate and login/logout users and I have a decorator
I have a site that will require a login by the users. The client
I have written a django page that requires only super users to login. So
Basically, I currently have login/ in urls.py redirect to the django.contrib.auth.views.login and that seems

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.