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

  • Home
  • SEARCH
  • 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 8584811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:51:36+00:00 2026-06-11T21:51:36+00:00

I have a simple view function, and a decorator for it, and I want

  • 0

I have a simple view function, and a decorator for it, and I want to use a parameter passed to view in the decorator. I’ve googled around but haven’t found any example for this, and I’m still not sure it this possible at all, and if so – how to do this?

View with decorator appended:

@user_is_project_maintainer
def edit(request, project_id_key):

decorator itself:

    def user_is_project_maintainer():
        def decorator(view_func):
            @wraps(view_func, assigned=available_attrs(view_func))
            def _wrapped_view(request, *args, **kwargs):
                if (project_id_key.isdigit()) :
                    project = get_object_or_404(Project, pk=project_id_key)
                else :
                    project = get_object_or_404(Project, key=project_id_key)

                if (project.maintainer_id != request.user.id) :
                    return HttpResponseRedirect(reverse('core.views.index', args=(project.key,)))
                else :
                    view_func(request, *args, **kwargs)

            return _wrapped_view
        return decorator

I’ve copied one of default django view decorators and amended it for my needs, I’m sure I’ve done it wrongly but it’s not the case. The main thing I can’t figure out – how to get my hands on the project_id_key var inside the decorator?

  • 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-11T21:51:37+00:00Added an answer on June 11, 2026 at 9:51 pm

    In _wrapped_view you have access to args and kwargs. So project_id_key should be available as args[0].
    But I would rather do it in more explicit way:

    def _wrapped_view(request, project_id_key, *args, **kwargs):
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple Django view that just returns URL parameters, but if I
I have a simple view function that's designed to allow the user to choose
I have a simple function that do this: 1) User view some image and
So I have a script which creates a simple table view, but changing a
I have a simple function that I want to call in the code behind
I have a simple function that should check if the view is at the
Say I have a simple view, MyView . If I do: SELECT * FROM
I am trying to write a url.py where I have a simple view for
I have a simple Backbone view which uses jQuery UI's buttons. For example I
I have a simple table view which is editable. All I need the user

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.